$set not working inside my own macro

100 views
Skip to first unread message

Eduardo P. Klein

unread,
Jul 9, 2015, 4:47:16 PM7/9/15
to tiddl...@googlegroups.com
Hi people!

I'm having trouble setting a variable inside a macro. It seems that the {{!!title}} field is not available for the $set macro inside my own macro.

\define TagHistory()

<$set name="tagName" value={{!!title}}>

$(tagName)$

    <$list filter="[tag[$(tagName)$]tag[Journal]!sort[title]]" />

</$set>

\end


Calling TagHistory shows nothing. But setting the variable outside the macro, in the calling tiddler, than it works.

What am I missing here?

Thanks,
Eduardo

Jed Carty

unread,
Jul 9, 2015, 5:19:15 PM7/9/15
to tiddl...@googlegroups.com
Here you need to use <<tagName>> instead of $(tagName)$ like this:


\define TagHistory()

<$set name="tagName" value={{!!title}}>

<<tagName>>

    <$list filter="[tag<tagName>tag[Journal]!sort[title]]" />

</$set>

\end

Note that there are single < and > around tagName in the filter instead of [ and ].

If you have something like this:

<$set name=tagName value={{!!title}}>
<<TagHistory>>
</$set>

then you could use $(tagName)$ inside the TagHistory macro.

This explaination may be missing some details, but the general difference between <<tagName>> and $(tagName)$ is when you use <<tagName>> it treats it like a macro and inserts the wikitext which is then evaluated, if you use a set widget outside a macro and then use $(tagName)$ inside the macro than the wikitext that defines tagName is evaluated before being passed into the macro.

Eduardo P. Klein

unread,
Jul 10, 2015, 9:24:33 AM7/10/15
to tiddl...@googlegroups.com
Thanks Jed!

It's always you bringing great solutions for me! I'm already a big fan of you :)

You know, that's the point where I usually get more trouble with TW... Those ways to transclude data with {{!! {! << < $ $( and so on... Maybe I'm mixing them up. The explanation seams plausible but then, when I think I understood it... I face a new situation.

Now I want to exclude the tag from the sublist, but I didn't find the solution. Look at the highlighted text. I tried many alternatives with no success.


\define TagHistory()

<$set name="tagName" value={{!!title}}>

  <ul>
    <$list filter="[tag<tagName>!sort[title]]">
      <$set name="tiddlerOfTag" value={{!!title}}>
        <li>
            <$link field="title"><$view field="title" /></$link> -
            <$list filter="[title<tiddlerOfTag>tags[]sort[title]]-[[Journal]]-<tagName>" >
                <$link field="title"><$view field="title" /></$link>
            </$list>
        </li>
      </$set>
    </$list>
  </ul>

</$set>

\end


If you know of any article that can give me a better understanting of this kind of problem, please point that to me, and I'll study it deeply. :)

Thanks,
Eduardo

Jed Carty

unread,
Jul 10, 2015, 1:13:57 PM7/10/15
to tiddl...@googlegroups.com
Like I said, missing details. You need to have [<tagName>] with the square brackets, square brackets always go around a filter expression.

Eduardo P. Klein

unread,
Jul 10, 2015, 1:31:43 PM7/10/15
to tiddl...@googlegroups.com
Thanks again Jed!

First thought was 'I tried that and didn't work'.

Guess what? It worked :D

Thank you very much, my journaling TiddlyWiki is getting better every day :)

Eduardo
Reply all
Reply to author
Forward
0 new messages