I don’t know much about wikitext. If I want to understand how it works I either just play around until it works or I read the javascript parser to figure out how it works. So I don’t have much wikitext experience.
What I do know is that {{{ ... }}}
is a filter parameter syntax, and the result of running that filter is assigned to the variable ptable in your first example. So when we get to the transclude widget, it’s looking at the result of having run that filter, not at the filter string itself.
<$let newline= {{{[charcode[10]]}}}
data="a 10; b 20; c 30"
ptable={{{ [<data>split[;]] :map:flat[enlist-input[]join[|]addprefix[|]addsuffix[|]] :and[join<newline>]}}} >
<$transclude $variable=ptable $mode=block/>
</$let>
In the same way, if you want to extract that filter out into a function, you need to run the function by setting a second variable to <<ptable>>
in order to get the result of the filter the same way {{{ … }}} did inline. So by the time $transclude sees it in my example, it’s again the result of running that filter.
\function ptable() [<data>split[;]] :map:flat[enlist-input[]join[|]addprefix[|]addsuffix[|]] :and[join<newline>]
<$let newline={{{[charcode[10]]}}}
data="a 10; b 20; c 30"
result=<<ptable>>
>
<$transclude $variable=result $mode=block/>
</$let>
If you replace function
with procedure
in your second example, it literally just prints the filter string. I would have expected function
to do that as well.
\procedure ptable() [<data>split[;]] :map:flat[enlist-input[]join[|]addprefix[|]addsuffix[|]] :and[join<newline>]
<$let newline= {{{[charcode[10]]}}}
data="a 10; b 20; c 30" >
<$transclude $variable=ptable $mode=block/>
</$let>
That was the thought process I used. I still am not exactly sure what people mean by saying the output of functions is not wikified, or that dom nodes are not included. But if I directly call the macro beside the transclude widget, you also get the undesired result.
Since the original filter result (not the filter itself) was being assigned to a variable using $let, moving that code into a function would require also assigning the result to a variable instead of attempting to transclude it. I guess it is a quirk of functions that when passed a filter, they run it??? I guess that’s why procedures were introduced.
So unlike Jeremy and Scott, I’m not recommending to use procedures because I can’t get them to execute the filter in the same was as the {{{ ... }}}
does inline or the function does when used in the same way.
Searching “triple curly braces” on tiddlywiki.com may give you more information.
https://tiddlywiki.com/#Widget%20Attributes