The :then Filter Run Prefix (a PR Under Review)


Following discussion by @saqimtiaz here and @Yaisog here

@Yaisog created a PR and developed the new :then filter run prefix. A demo is available for test. See

Use cases

This filter run prefix is very useful, as it is one of the missing filter prefix in TiddlyWiki filter language. In general you can use it like

<$list filter="[condition] :then[true-part] :else[false-part]">

For example see:

<$edit-text field="search" placeholder="Search title"/>

<$let searchTerm={{!!search}}>
<$list filter="[<searchTerm>minlength[3]] :then[!is[system]search:title<searchTerm>]" template="$:/core/ui/ListItemTemplate"/>

You can contribute: I am sure you can give a try and add your own use cases/examples here.


Example: A Three-Way Conditional View Template

Write a wikitext script to transclude tiddlers through:

  • Template1 if a tiddler tagged with parent BUT NOT with second
  • Template2 if a tiddler tagged with parent and also with second
  • baseTemplate if a tiddler not tagged with parent NOR with second
<$list filter="
  emptyMessage={{baseTemplate}} variable=thisTemplate>
      <$transclude tiddler=<<thisTemplate>> mode=block />

Example: Conditional Default Tiddlers If Wiki Served over a Certain URL

Write a filter for $:/DefaultTiddlers to show different set of default tiddlers with below conditions.

  • if served over show all tiddlers tagged HelloThere
  • if not (like opened from local drive) show all tiddlers tagged Start

To implement this:

  • Open $:/ControlPanel
  • Open Info tab and then → Basics tab
  • In Default Tiddler input box enter the below filter

This is a simple example worth to be included into doc.