Introduce Multi-valued Variables and Let Filter Run Prefix - Examples

Jeremy recently added a new fiter rub prefix to TiddlyWiki Filter Language. See

He stated that:

This PR introduces a new filter run prefix :let that assigns the result of the filter run to a variable that is made available for the remaining filter runs of the filter expression.

It solves the problem that otherwise it is impossible to compute values for filter operator parameters; parameters can only be a literal string, text reference or variable reference. The :let filter run prefix provides a solution:

[my.custom.function<param>,[2]] :let[[index]] [<data>jsonget[top],<index>]

The shortcut syntax => can also be used:

[my.custom.function<param>,[2]] =>index [<data>jsonget[top],<index>]

Using the shortcut syntax also avoids having to use double square brackets around the name of the variable.

This example first sorts all the input tiddlers by length, and then uses the length of the shortest title as the second index of a JSON lookup:

[all[tiddlers]] :sort:number[get[text]length[]] :let[[index]] [<data>jsonget[top],<index>]

This PR also introduces the ability for multi-valued variables which contain list of results, not just single strings. They can be assigned with the new :let filter run prefix, or the existing <$let> widget. The full list of values can be retrieved using round brackets instead of the usual angle brackets. In all other contexts only the first item in the list is used as the variable value.

This seems exciting. You can evaluate this new feature on TiddlyWiki Pre-release — 5.4.0-prerelease

See also official doc: https://tiddlywiki.com/prerelease/#Let%20Filter%20Run%20Prefix
My question is: Can you give some simple examples can be use by an intermediate TW user?

1 Like