Filter problem: "then...else" but carrying the input

A simple then[foo]... else[bar] can, AFAIK, only pass on the simple operand strings but is not usable if you want the input to follow along and be manipulated. What can I do for the latter?

Specifically this concerns my problem in the peculiar PR so here is a simplified example of this where I’m attempting here using the :else filter run prefix:

<$let remove='</$button>' >
{{{ [[mytiddler]get[text]] +[removesuffix[
]addsuffix[hey]] :else[addsuffix[hey]] }}}
</$let>

Thus I want to test if the text ends with an empty line and in that remove the empty line and do something more, alternatively if it doesn’t then do something.

…but is the text at all carried to the :else statement? Is :else just wrong? Maybe the + messes things up? ?

(Plus I vaguely recall some a more elegant regex to express line breaks instead of the silly chop[
]up… but this is less important.)

Any suggestions?

Thanks!

1 Like

I really don’t understand why you want to take this approach and would advise you to reconsider since it seems inherently brittle.

In terms of the filter, I think you want something like this:


{{{ [[mytiddler]get[text]removesuffix[
]addsuffix[hey]] :else[[mytiddler]get[text]addsuffix[hey]] }}}
2 Likes

But how else can I solve it :frowning: - except for “waiting” until we have the “wikitext based affordances for js hooks” and these are integrated into the core buttonwidgets (ref) - which might of course never happen.

I warmly welcome any more robust solution. The end goal is to provide a plugin for people who prefer that deleting or closing a tiddler via the tiddlers tools, should navigate to the tiddler previous in the StoryList (typically the tiddler they “came from”)

Thank you for the filter! :smiley:

Overwrite the core buttons, or implement new replacement buttons. I would considering overwriting a shadow tiddler to be cleaner than a search/replace type of approach.

Ah, right, I did take that route into consideration - maybe I chose the wrong approach but I’m considering the tradeoff that updates to the core button would then be fully overwritten if my plugin had “complete” tiddlers. Instead, my approach assumes that the core buttons will always end with a closing buttonwidget tag (…plus a possible pesky line break) but it will be simple for the user to delete the overwrite and just fire my plugin again to inject the navigation command. I will probably not have to update the plugin in a very long time and the user can probably use it for a very long time, even after core updates.
I should write a note about this though, in the plugin readme.

Thank you!