When prefix is currentTiddler + comma

I have this filter in viewtemplate:

<<tabs "[!is[system]prefix<currentTiddler>sort[caption]] -[<currentTiddler>]" "" "$:/state/tab1" "tc-vertical">>

But I would like to change it so that it grabs only the tiddlers that star with currentTiddler followed immediately by a comma. But not the others that have the currentTiddler but no comma immediately following.

What do I need to do?

Currently, until we have prametrized transclusions, I’d say you need to use a macro to concatename current with a comma and refer to it, something like

\define curr() $(currentTiddler)$,

<$let curr=<<curr>>>
<<tabs ... >>
</$let>

(I didn’t test it)

2 Likes

Try changing the filter along these lines:

[!is[system]] :filter[removeprefix<currentTiddler>prefix[,]] :and[sort[caption]] -[<currentTiddler>]

Thanks TWMat and Saq, but neither of these work…

TWMat’s makes a tab of every tiddler in the file. In Saq’s, nothing appears.

Saq, why use “removeprefix”? (I also tried it with prefix instead of removeprefix, with no results.

Apologies Dave, there is a typo as a result of typing this out on a touch screen:

[!is[system]] :filter[removeprefix<..currentTiddler>prefix[,]] :and[sort[caption]] -[<currentTiddler>]

The logic behind removing the prefix if it exists, is that you can then check if the remaining text has a prefix of the comma character. The entire run starting with :filter is like a sieve that only lets through the titles that meet those criteria.

2 Likes

@saqimtiaz I think I am also I correct in saying;

removeprefix<..currentTiddler> also only operates on and if, the tiddler has the prefix “current tiddler” thus also performing the initial filtering, that a simple prefix would also do.

I do not understand what this means. If you have alternative and equivalent code to propose please post it.

@saqimtiaz

As asked,

I could have expanded my words further.

I am stating, in part, how the remove prefix removeprefix<..currentTiddler> also only acts on tiddlers beginning with “current Tiddler”, which is what @DaveGifford was trying to understand, he thought the “prefix” operator was appropriate.

  • That is there are cases such as removeprefix `which are a filter and an action.
  • I wanted your view / confirmation since this is occurring inside the “:filter” run.
1 Like

Here’s a more verbose description of what Saq’s filter syntax is doing:

  • Outside of the :filter[...] syntax, <currentTiddler> refers to the tiddler containing the <<tabs>> macro.

  • However, within the :filter[...] syntax, <currentTiddler> refers to each of the tiddlers found by the preceding filter run (i.e.,[!is[system]).

  • To refer to the original tiddler containing the <<tabs>> macro from within the :filter[...] syntax, we need to use the special filter variable, <..currentTiddler>.

  • Thus, within the :filter[...] syntax, using removeprefix<..currentTiddler> identifies titles matched by [!is[system] that start with the original tiddler title, and also removes that leading title text, so that the subsequent [prefix[,]] syntax can check to see if the rest of the matched title starts with a comma.

  • The result of processing the :filter[...] run is that only tiddlers that match [!is[system] and also start with the title of the containing tiddler followed by a comma are retained for processing by the remainder of the filter runs (i.e., :and[sort[caption]] -[<currentTiddler>]). Q.E.D

-e

2 Likes

Which is what I was trying to say, thanks for your clarity Eric.

Thank you to everyone for yourhelp and explanations. It is snowing hard here in Michigan and we were out on a visit. I will look at it now.

2 Likes

aaaand it works like a charm. And now I even am starting to understand how it works!

3 Likes