I’ve just found out the hard way that variable substitution are occurring within \define where they should not and not eleswhere and especially not within \procedure.
The code:
\define buggy()
<ol>
<$list variable=hole filter="[prefix[sub]]">
<$let part01 = {{{ [[insert $(hole)$ @$(currentTiddler)$]] }}}
part02 = {{{ [[insert $(hole)$ @$(currentTiddler)$]substitute[]] }}}
>
<li>part01: <<part01>> THEN part02: <<part02>></li>
</$let>
</$list>
</ol>
\end
\procedure correct()
<ol>
<$list variable=hole filter="[prefix[sub]]">
<$let part01 = {{{ [[insert $(hole)$ @$(currentTiddler)$]] }}}
part02 = {{{ [[insert $(hole)$ @$(currentTiddler)$]substitute[]] }}}
>
<li>part01: <<part01>> THEN part02: <<part02>></li>
</$let>
</$list>
</ol>
\end
!! buggy
<<buggy>>
!! correct
<<correct>>
Try it on tiddlywiki.com on a tiddler named “bug” and see the below output:
=======
buggy
part01: insert @bug THEN part02: insert @bug
part01: insert @bug THEN part02: insert @bug
part01: insert @bug THEN part02: insert @bug
part01: insert @bug THEN part02: insert @bug
part01: insert @bug THEN part02: insert @bug
part01: insert @bug THEN part02: insert @bug
part01: insert @bug THEN part02: insert @bug
part01: insert @bug THEN part02: insert @bug
correct
part01: insert $(hole)$ @$(currentTiddler)$ THEN part02: insert subfilter Operator @bug
part01: insert $(hole)$ @$(currentTiddler)$ THEN part02: insert subfilter Operator (Examples) @bug
part01: insert $(hole)$ @$(currentTiddler)$ THEN part02: insert substitute Operator @bug
part01: insert $(hole)$ @$(currentTiddler)$ THEN part02: insert substitute Operator (Examples) @bug
part01: insert $(hole)$ @$(currentTiddler)$ THEN part02: insert subtiddlerfields Operator @bug
part01: insert $(hole)$ @$(currentTiddler)$ THEN part02: insert subtiddlerfields Operator (Examples) @bug
part01: insert $(hole)$ @$(currentTiddler)$ THEN part02: insert subtract Operator @bug
part01: insert $(hole)$ @$(currentTiddler)$ THEN part02: insert subtract Operator (Examples) @bug
=======
In \define
’ variable er immediately substituted but not with their values but with empty contents.