{{{Filtered transclusion}}} in widgets don't work properly?

I know @saqimtiaz recently posted some warning about filtered transclusions in some widget but I cannot locate it. Maybe this is a double of that information, or maybe it is new, or maybe I just misunderstand something, but the following does not work and I don’t understand why:

<$text text={{{ a b }}} />

I was expecting the output to be a b but the output is only a

Same erroneous result with:

<$view tiddler={{{a b}}} field=title />

and

<$set name=x value={{{a b}}}> <$text text=<<x>>/> </$set>

Try this and see if you can tell what’ s going on and how this can be used:

<$text text={{{ a b +[join[::]] }}} />

When you use a filtered transclusion to specify a widget attribute, only the first first result returned by the filter is used.

If you want to use all the returned results you can do this:

<$text text={{{ [<!---my filter --->format:titlelist[]join[ ]] }}} />

See the section on “Filtered Attribute Values” at: https://tiddlywiki.com/#HTML%20in%20WikiText

Edit (copied relevant documentation):

Filtered Attribute Values

Filtered attribute values are indicated with triple curly braces around a Filter Expression. The value will be the first item in the resulting list, or the empty string if the list is empty.

This example shows how to add a prefix to a value:

<$text text={{{ [<currentTiddler>addprefix[$:/myprefix/]] }}} />

The attribute’s value will be the exact text from the first item in the resulting list. Any wiki syntax in that text will be left as-is.

That works! Thanks!

Is this intentional? If “yes”, then why? To get only the first item, it is trivial to add first[] in contrast to the solution you provide above.

It also breaks my “mental model” that triple braces “enclose” the argument like e.g triple quotes do.

Thanks @Charlie_Veniot - but this (obviously) joins the items into one… so what is your idea that I would do with that output? Besides, couldn’t I just have used the input a::b then?

With that said, if join[::] is replaced with just join[ ] then it is basically what Saq suggests.

That to me is a rather odd mental model and probably worth revisiting. I cannot honestly see anything in common between triple quotes and triple braces.

Triple quotes are for the exceptional situation where you need to pass a literal string as an attribute which itself contains quotes. Their need in macros should already be diminished if not eliminated by the <__paramname__> syntax for accessing macro parameters.

If you know ahead of time, such that you can “hard code” the tiddler titles, then you can certainly manually join them in a list by typing each tiddler title out individually.

The reason for the join is so that whatever is before it, however complicated a filter that yields however many tiddler titles, they will all get strung up into one item.

The reason for the “::” in the join is to make it ridiculously easy to “split” that item into the multiple titles if needed. (EDIT: i.e. make the join-string-of-characters something that will likely never actually be part of a tiddler title, or part of whatever list of items is generated by the filter, because the filter could be getting something other than titles. So maybe “:::” would be better, or an emoji of some kind, like “:small_blue_diamond:”)

All setup for generic usage (i.e. pretty much any kind of use case one could think of for that one item that actually contains many.

2 Likes