<$list filter="[all[current]!is[system]has[one]] [all[current]!is[system]has[two]] [all[current]search:text[three] -[last[]]">
<$link/> |
</$list>
<$list filter="[all[current]!is[system]has[one]] [all[current]!is[system]has[two]] [all[current]search:text[three]
+[last[]]">
<$link/>
</$list>
--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/af4a5ac3-13e3-4f62-9a91-7fc765e20c80n%40googlegroups.com.
I am sure this has been addressed before but I cannot find it in forum
Assume you have a complex filter that results in an output containing few tiddlers. Then you want to show them with a delimiter e.g. pipe (|)
One solution is below. I am looking for a more efficient solution! I assume here TW makes the search two times! I know we can use a $set widget here, but what better solution do you propose?
--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/b1fc22c4-d4e7-4f45-a26a-7f0757618dd2n%40googlegroups.com.
On Sunday, August 1, 2021 at 9:48:12 AM UTC-7 Atronoush wrote:I am sure this has been addressed before but I cannot find it in forumAssume you have a complex filter that results in an output containing few tiddlers. Then you want to show them with a delimiter e.g. pipe (|)One solution is below. I am looking for a more efficient solution! I assume here TW makes the search two times! I know we can use a $set widget here, but what better solution do you propose?Overall, an interesting challenge in TiddlyWiki filtering.I had fun trying several approaches...The most efficient one is to use $set, as you suggested, like this:<$set name="out" filter="[tag[HelloThere]] [tag[About]] [tag[Platforms]]"><$list filter="[enlist<out>butlast[]]"><$link/> | </$list><$list filter="[enlist<out>last[]] "><$link/> </$list></$set>
The improvement is that the filter is only evaluated once, with two enlist[] operators added. Depending upon how many matching tiddlers are found, and assuming a reasonably short list, the enlist[] operators are likely to be more efficient than evaluating the filter twice. Also, note the use of -[last[]] in your initial post is incorrect... it doesn't actually remove the final item. The correct operator to use is butlast[], as shown above.I also tried this:<$set name=out filter="[tag[HelloThere]] [tag[About]] [tag[Platforms]]"><$vars last={{{ [enlist<out>last[]] }}}><$list filter="[enlist<out>]"><$link/> <$text text={{{ [<currentTiddler>!match<last>then[|]] }}}/> </$list></$vars></$set>The improvement here is the same as above, except that uses an extra variable ("last") and an inline filter to decide when to insert the "|" between items, so it's obviously a bit less efficient.Lastly, I tried this:<$vars lb="[[" rb="]]"><$set name=out filter="[tag[HelloThere]] [tag[About]] [tag[Platforms]]"><$wikify name="out" text="""<$list filter="[enlist<out>addprefix<lb>addsuffix<rb>join[ | ]trim[ | ]]" ><$link/></$list>"""><<out>></$wikify></$set></$vars>Of course, this is even less efficient than the previous solutions, as it uses wikify to produce the output, and needs to explicitly add brackets around the links. However, it does demonstrate the use of join[] and trim[] to insert the "|" between items.-e
--
<$set name="out" filter="[tag[HelloThere]] [tag[About]] [tag[Platforms]]"><$list filter="[enlist<out>butlast[]]"><$link/> | </$list><$list filter="[enlist<out>last[]] "><$link/> </$list></$set>Is it possible to use subfilter instead of enlist here? Which is recommended?<$set name="out" filter="[tag[HelloThere]] [tag[About]] [tag[Platforms]]"><$list filter="[subfilter<out>butlast[]]"><$link/> | </$list><$list filter="[subfilter<out>last[]] "><$link/> </$list></$set>
--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/3d1a2020-eade-43a1-95fa-6a9c71f6aaf3n%40googlegroups.com.