Transclusion to set a macro/procedure's default parameter value

I feel this is probably relatively trivial, but for some reason, I have not yet managed to make it work (meaning a filter relying on this parameter isn’t behaving reliably).

I am working on a flexible plugin. I would like to have a few settings that can be configured through a configuration page. I also would like these settings to be “default values” for my main macro, but also allow the user to override these defaults when they call the macro (named parameter).

This I feel would be most flexible; some users may have a greater need/preference to call with one value over another. That is what they should set as default value in the configuration page. Then for the minority of their exceptions, they could override the default value with (named) parameters upon invoking the macro. Other users could use the macro the other way around by setting the opposite value as default and overriding only when needed.

Here’s what I tried:

\define my-awesome-macro(flexibleParam:{{$:/plugins/config/default-param-value}})

<$list filter="[[$flexibleParam$]match[yes]]" variable="null">

[...]
 
</$list>

\end

then you could invoke using <<my-awesome-macro>> or <<my-awesome-macro flexibleParam="yes">>

This works if I hard-code the default value; doesn’t quite work if I try transcluding the default value from a config tiddler’s main text field, as above.

Any insight?

oh, I think I may have found something relevant here: https://tiddlywiki.com/#Pragma%3A%20\procedure

I’ll post if this doesn’t work.

It works; basically one needs to use procedures and not macros, and one needs to use the parameters widget.

2 Likes