Filter syntax: "distribute" a filter op onto a list of arguments

50 views
Skip to first unread message

Mat

unread,
May 30, 2020, 7:27:48 AM5/30/20
to TiddlyWiki
To avoid having to dig inside a tiddlers code, I want to conveniently add items to a list in a macro definition at top of the tiddler or perhaps in some field.
For example, the items might be a list of tags.
The items are then, individually, to serve as arguments to some filter operator.
For example:

\define myarguments() foo bar baz

<$vars mytags=<<myarguments>> >
{{{ [tag<mytags>] }}}
</$vars>

How can this be made to work?

Thank you!

<:-)


Leander

unread,
May 30, 2020, 8:28:32 AM5/30/20
to tiddl...@googlegroups.com
\define myarguments() foo bar baz

{{{ [enlist<myarguments>tagging[]] }}}

Does the trick in your example. You need a filter operator that takes a list as input for this though, so it's somewhat limited.

Edit: A more flexible way and what you're probably looking for is

\define myarguments() foo bar baz

<$list filter="[enlist<myarguments>]" >

{{{ [tag{!!title}] }}}

</$list>

Joshua Fontany

unread,
May 30, 2020, 6:45:38 PM5/30/20
to TiddlyWiki
Exactly how I would approach it.

In order to store the myargument() definition and the "invoking" widget separately (i.e. in separate tiddlers) you have a few options.

Store it in any tiddler tagged `$:/tags/Macro`. This allows invoking the variable valuw from any scope/context within the wiki, and also allows "local overrides", i..e you can re-define it in another tiddler without that tag, and within that tiddler's scope it will have the new value.

Or, you can store it in any tiddler, and in the tiddler you want to invoke it in, you put the pragma `\import [[NameOfTidWith
Definition]]` (the param in a filter, so you can import multiple bun tag with `[tag[TagToImport]]`, etc). This imports all macro definitions into the current scope.

Best,
Joshua Fontany
Reply all
Reply to author
Forward
0 new messages