TiddlyWiki / TiddlyWiki5

A self-contained JavaScript wiki for the browser, Node.js, AWS Lambda etc.
https://tiddlywiki.com/
Other
8.04k stars 1.19k forks source link

List transclusion for attributes #2126

Closed tobibeer closed 11 months ago

tobibeer commented 8 years ago

I just tried this to see if it worked:

<$text text={{{[tag[HelloThere]]}}}/>

It didn't... but I think it may be useful.

Jermolene commented 8 years ago

Hi @tobibeer perhaps that's not a great example because it could be formulated very easily to use the existing list widget.

The thing is that the list widget incorporates extensive logic to perform selective updates when elements of the list change. It would be impossible to transform that logic so that it worked with the syntax proposed here.

It seems like in general one could always use a macro to accomplish the same thing:

<$text text=<<myMacro "[tag[HelloThere]]">>/>
tobibeer commented 8 years ago

Ok.

tobibeer commented 8 years ago

Well, actually... it's not at all the same, because the end result is an actual transclusion and not whatever markup makes for the transclusion, e.g. as myMacro would return.

\define myMacro(filter) {{{$filter$}}}

<$text text=<<myMacro "[tag[HelloThere]]">>/>

sets text to {{{[tag[HelloThere]]}}}

\define myMacro(filter) {{{$filter$}}}

<$text text={{{[tag[HelloThere]]}}}>>/>

...sets text to: foo bar baz ...assuming those where the tiddlers tagged HelloThere.

So, all that needs doing is to compile a filter and return the results to the attribute.

buggyj commented 8 years ago

do you mean this? <$set name=x filter=[tag[HelloThere]]> <$text text=<<x>>/>

tobibeer commented 8 years ago

Sure, it's somewhat the same, but one thing is simply an attribute declaration, and the other an additional variable.

pmario commented 11 months ago

@Jermolene ... This one can be closed, because we can solve the problem with <$text text={{{ [tag[HelloThere]format:titlelist[]] +[join[ ]] }}}/>

Jermolene commented 11 months ago

Thank you @pmario