Can I use <$transclude> inside <$codeblock>?

56 views
Skip to first unread message

Scott Sauyet

unread,
May 11, 2020, 2:38:39 PM5/11/20
to TiddlyWiki
I would like to grab some code for a codeblock from the text of another tiddler, all taking place inside a <$list>.  This is what I tried:

<details>
  <summary>Helpers</summary>
  <$list filter="[tag[MyTag]sort[title]]">
    <$link><$transclude field="name" mode="block"/></$link>
    <$codeblock language="javascript"><$transclude field="text" mode="block"/></$codeblock>
  </$list>
</details>

But that doesn't properly get the text.  Just plain transcluding the field works fine:

    <$transclude field="text" mode="block"/>
 
And of course a codeblock that gets its data from another tiddler works fine:

<details>
    <summary>Schema</summary>
    <$codeblock code={{MyTiddler}} language="json"/>
</details>

But my attempt to combine them didn't work.  Nor did several other syntaxes I guessed at.  Is there a good way to do this?

  -- Scott


Mark S.

unread,
May 11, 2020, 3:13:48 PM5/11/20
to TiddlyWiki
This seems to work:

 <details>
     
<summary>Helpers</summary>

      <$list filter="[tag[MyTag]sort[title]]">
        <$link><$view field="name" /></$link>
        <$codeblock language="javascript" code={{!!text}}  field="text" />
      </$list>
   
</details>

Note this comment from tiddlywiki.com:

The content of the <$codeblock> widget is ignored.

HTH

Scott Sauyet

unread,
May 11, 2020, 4:31:22 PM5/11/20
to tiddl...@googlegroups.com
Thank you very much.  That worked fine.

I tried all sorts of variants that seemed vaguely likely, but not that one.  Every time I get back into doing something significant with TW, I have to relearn the model.  I know that it's fairly logical and self-consistent, but I can't seem to keep it in my head.

  -- Scott

Mark S.

unread,
May 11, 2020, 5:00:27 PM5/11/20
to TiddlyWiki
In this case remember that:

{{mytiddler}}

will transclude the text field of mytiddler

{{mytiddler!!myfield}}

will transclude the contents of the field "myfield" of "mytiddler".

And

{{!!myfield}} will transclude the contents of the field "myfield" of the current tiddler.

Inside of a list widget, unless you specify a variable name, the current tiddler is the tiddler the list is currently on.

HTH
Reply all
Reply to author
Forward
0 new messages