>
> If I define & use macros as 
>
> \define foo() 42 
>
> \define bar() <<foo>> 
>
> <span><<bar>></span> 
>
> The expansion works as I'm expecting it to, and the output is 
>
> <span>42</span> 
>

Macros only do text substitution and then transclude the resultant string. 
So the macro <<bar>> returns <<foo>> but the entire string is then wikified 
as it is part of the wikitext of a tiddler, that is it is run through the 
parser and the rendered result ends up in the DOM. Under the covers, macros 
are variables.
 

> \define foo() 42 
>
> \define bar() <<foo>> 
>
> <span class=<<bar>>></span> 
>
> Then the expansion yields 
>
> <span class="<<foo>>">test</span> 
>

When you use variable widget attributes (or indirect attributes via 
references), the value of the variable is fetched/transcluded and that 
literal value is assigned to the attribute. There is no further 
wikify/rendering step.
 
The difference is in context. In the first example the macro is used in 
wikitext and is wikified/rendered after transclusion. In the second the 
macro is assigned to an attribute, and the value is transcluded but there 
is no wikify/render step.

You can use the wikify widget to render a macro and assign the rendered 
value to a variable for further use. This should be a last resort as it 
comes with a refresh performance penalty and can almost always be avoided 
with alternative code patterns.

Note that the rules of assigning attributes to HTML elements and widgets 
are the same, as under the covers all HTML elements are handled by an 
<$element> widget.

Hope this helps.
Saq

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tiddlywiki+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/de98d917-c29f-46a9-921d-6b37996b9433n%40googlegroups.com.

Reply via email to