How to alter your use of tiddlywiki according to its version!

Folks,
I was writing some code where I saw value using a new feature in Version 5.2.0 however the solution I was building would be useful on existing wikis that I may have no reason (yet) to upgrade).

As a result, I asked myself;

How can I choose different results depending on the existing tiddlywiki version?

In short with the compare operator, itself only NEW IN: 5.1.22, we can use a version compare;

Here is a minimal example;

<$list filter="[<version>compare:version:gteq[5.2.0]]" emptyMessage="Not gteq v5.2.0" variable=nul>
   gteq v5.2.0
</$list>
  • So inside this list you can put any wiki text that demands tiddlywiki greater than or equal to version 5.2.0
  • you can also remove or modify the emptyMessage parameter for when the condition is not true, this can even be more wiki text defined in a macro eg: emptyMessage=<<othercode>>

sub hint

  • I set the variable=nul on the list so the currentTiddler variable is not changed inside the list in case I need access to it.
  • nul is just another variable which I use if I will not make use of it in the list. If I decide to make use of the value I will rename it to a suitable name. In this case we could call it version (although in this case it is redundant because the <<version>> macro also works.

For example

<$list filter="[<version>compare:version:lteq[5.2.0]]" variable=version emptyMessage="Not lteq v5.2.0">
   <<version>> is lteq v5.2.0
</$list>

Please like this post if this How to proves helpful.

I do like these examples.
-m

Edit: I did misread the first example. So the initial comment doesn’t make much sense, except, that I do like the examples.

@pmario I am happy to change it, but is there something wrong with the first, I only go on to illustrate why I used variable=nul?

Sorry. … Forget my comment. I did misread the gteq … I think it’s compared with equal, which would only work with 5.2.0 …

1 Like