How to "generate" filter?

119 views
Skip to first unread message

bimlas

unread,
Dec 14, 2018, 7:59:27 AM12/14/18
to TiddlyWiki
I would like to generate a filter from a predefined list, for example:

List: a b c
Generated filter: [tag[a]tag[b]tag[c]]

So far, wikify has solved the task, but Jeremy pointed out that this is a bad habit (so you have to avoid this, but you can try out on https://tiddlywiki.com/):

<$wikify name="filter" text="""[<$list filter="a b c">tag[<$text text=<<currentTiddler>>/>]</$list>]""">
Wikified filter expression: <$text text=<
<filter>>/>
</$wikify>

The question is, how can I even compile filter expressions?

bimlas

unread,
Dec 14, 2018, 8:19:47 AM12/14/18
to TiddlyWiki
Apart from generating the filter, it would also be appropriate to store the filter output, which Mohammad is also interested in.

https://groups.google.com/forum/#!topic/tiddlywiki/ENSs0lDkL68

bimlas

unread,
Dec 14, 2018, 8:33:12 AM12/14/18
to TiddlyWiki
OK, just found a solution for storing filter output:

<$set name="output" filter="a [[b c]] d">

<$macrocall $name="list-links" filter=<<output>>/>

</$set>

Mark S.

unread,
Dec 14, 2018, 10:12:16 AM12/14/18
to TiddlyWiki

I would like to generate a filter from a predefined list, for example:

List: a b c
Generated filter: [tag[a]tag[b]tag[c]]

So far, wikify has solved the task, but Jeremy pointed out that this is a bad habit (so you have to avoid this, but you can try out on https://tiddlywiki.com/):


Hmm. He doesn't mention why it's a bad idea. I imagine it has something to do with performance.

But there is that saying, "When all you have is a hammer, everything starts to look like a nail.".

In this case, you may have other tools

In most situations couldn't you use something like:

<$set name="mytags" value="A B C">
<<list-links "[enlist<mytags>tagging[]]">>
</$set>
 
?

Without seeing how you are using the filter, it's hard to know what your really need.

Have fun!
-- Mark

Jeremy Ruston

unread,
Dec 14, 2018, 10:21:43 AM12/14/18
to tiddl...@googlegroups.com
Hi Bimlas
I think this example is OK, and a reasonable way to accomplish what you want. The problem with the example we were discussing on that link was that tiddler titles containing certain wikitext constructions would fail. Here you’re using the right techniques to avoid that (ie using the <$text> widget instead of transcluding the variable with <<currentTiddler>>).

Best wishes

Jeremy.



--
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 post to this group, send email to tiddl...@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/415d6b91-fbbd-43a4-8ca8-719be40cc23e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Mark S.

unread,
Dec 14, 2018, 10:46:58 AM12/14/18
to TiddlyWiki
Never mind. I just realized my example won't work.

Sorry!
-- Mark

bimlas

unread,
Dec 14, 2018, 11:42:09 AM12/14/18
to TiddlyWiki
@Mark:

I understand what you think and agree, the <$set> is a good solution - just found for a couple of hours ago, I used <$vars> earlier, but it was not able to store the filter output.

<$set name="output" filter="[tag[Filter Operators]first[5]]">
 
Text of variable: <$text text=<
<output>>/>
 
List of titles: <$macrocall $name="list-links" filter=<
<output>>/>
 
</$set>

@Jeremy:

I understand, so the issue it's not the use of <$ wikify>, but it's unanticipated consequences. Thanks!

Mohammad

unread,
Dec 14, 2018, 1:22:36 PM12/14/18
to TiddlyWiki
This is wonderful!
Storing the results of a list (filter) operation! It can be used in many ways!
like passing to a macro or use in sub-operation. 


--Mohammad

Jeremy Ruston

unread,
Dec 14, 2018, 5:04:22 PM12/14/18
to tiddl...@googlegroups.com
Hi Mohammad

Storing the results of a list (filter) operation! It can be used in many ways!

If you’re storing the list that results from evaluating a filter then you can use the set widget: <$set name=foo filter=[tag[mytag]]>; you can use the resulting list with the new “enlist” operator.

The trick with wikify is only needed if you are dynamically building a filter string for later evaluation.

Best wishes

Jeremy


TonyM

unread,
Dec 14, 2018, 8:25:35 PM12/14/18
to TiddlyWiki
Bimlas,

What about a local or Global macro like this

\define output-filter() [tag[Filter Operators]first[5]]


<$list-links filter:"[subfilter<output-filter>">>
This has no need to terminate the set widget and uses a lot less text where used, if you choose a good name for "output-filter" it will read even better.

here I have requested an alias for the subfilter operator so you could write;
<$list-links filter:"[filter<output-filter>">>


Regards
Tony

Mohammad

unread,
Dec 15, 2018, 7:46:05 AM12/15/18
to TiddlyWiki
Hi Jeremy,

These are great features. I am thinking TW can act as a high level wiki programming environment!
The only drawback is documentation, I hope with the new policy for updating documentations on tiddlywiki.com,
this issue could be addressed.


-- Mohammad

TonyM

unread,
Dec 15, 2018, 10:01:59 PM12/15/18
to TiddlyWiki
Sorry my last reply miss formated the list links with a <$ not a <<

<<list-links filter:"[subfilter<output-filter>">>
Reply all
Reply to author
Forward
0 new messages