How to pass contents of a tiddler to the filter?

I want to use the contents of the tiddler $:/config/NewJournal/Tags inside a filter with tag operator.

Currently, it only has one string Journal. But it can get more entries, like Journal [[example tag]]


Things that I have tried :sweat: and failed.

I expected following attempts to work at least when {{$:/config/NewJournal/Tags}} evaluated to a single string i.e. Journal. But I was wrong.

One

{{$:/config/NewJournal/Tags}}

I expected translusion to work inside the filter.

<$list filter="[tag[{{$:/config/NewJournal/Tags}}]]" />

Failed :-1:

Two

I noticed that list operator can show the content this way

<$list filter="[list[$:/config/NewJournal/Tags!!text]]" />

So I tried same syntax with tag operator

<$list filter="[tag[$:/config/NewJournal/Tags!!text]]" />

Failed. :-1:

Three

<$vars example1="$:/config/NewJournal/Tags">
<$list filter="[tag<example1>]" variable="ignore">

Failed. :-1:

how about [tag{tiddlername goes here}]? that should work at least for the single tag situation.

When referencing tiddler contents within filter syntax:

  • The delimiters surround the filter operand indicate how the operand is to be processed:
    • square brackets – [text]– surround literal text
    • angle brackets – <variablename> – surround variable references
    • curly braces – {tiddlername}, {!!fieldname}, or {tiddlername!!fieldname} – surround tiddler field references

Note that, while doubled delimiters – [[tiddlerlink]], <<variablename>>, or {{fieldreference}}– are used within regular wikitext, single delimiters – [text], <variablename>, or {fieldreference} – are used within filter syntax.

Thus, for your purposes, you could write: [tag{$:/config/NewJournal/Tags}]. However, as you have noted, the tag filter operator only works with single tag values. To filter for multiple tag values, you can use a combination of enlist and tagging filter operators, like this:

<$list filter="[enlist{$:/config/NewJournal/Tags}tagging[]]" />
  • The enlist{$:/config/NewJournal/Tags} operator retrieves the text field value contained in $:/config/NewJournal/Tags and processes it to convert a space-separated, bracketed list into multiple individual items.
  • The tagging[] operator then processes each individual item in turn to find all tiddler titles that are tagged with each of the listed items. The resulting titles are automatically “de-duplicated” so that each title is listed only once in the final result.

enjoy,
-e

4 Likes

the problem with tagging is that it will give you the tiddlers tagged with any of the tags you pass it.

I don’t know if that’s what @talha131 wants… but if it is, we’re done.

If not, I guess we’ll need to mess with filter runs, perhaps :intersect or map

Can’t thank you enough @EricShulman

I did notice these syntax differences and wondered about their significance when going through macros from other experts. Great explanation. You answered my several questions with one shot.

I am trying to customize journal-book macro. @EricShulman answer removed the roadblock.