Trying to show the title after removing it's suffix from it if it has a matching suffix, otherwise just show the title

I’m tinkering with button templates and trying to list all tiddlers that are tagged as Checklists, many of which have “Checklist” as a suffix, but some do not.

I wanted to create a filter that will remove the Checklist suffix from any tiddler that has it, but if it doesn’t (lets say, a tiddler tagged checklist with the title of Grocery List) just to show the title.

<$tiddler tiddler=<<currentTab>> >
<$list filter="[<currentTab>has:suffix[Checklist]removesuffix[Checklist]else<currentTab>]">
<$view field="title"/>
</$list>
</$tiddler>

Above is what I’ve tried so far, but I can’t seem to figure out what isn’t working with it.

I figured out that I was using the suffix operator incorrectly :sweat_smile:

Correct way to do it is:

<$tiddler tiddler=<<currentTab>> >
<$list filter="[<currentTab>suffix[Checklist]removesuffix[Checklist]else<currentTab>]">
<$view field="title"/>
</$list>
</$tiddler>

A shorter way to do this:

<$text text={{{ [<currentTab>trim:suffix[Checklist]] }}}/>
1 Like

wow, that’s awesome, thank you!