Conditional Shortcut Syntax listing <%elseifs

When using the Conditional Shortcut Syntax, is there any way to use the $list widget to generate a list of <%elseif conditions instead of manually writing them all out? I don’t seem to be able to transclude in an <%elseif in any way at all…

The %if is a single condition that is true or false, and interestingly when true sets the variable condition.

The idea of nesting $list widgets was a key design approach, until the %if arrived.

If you want an if or elseif test to be applied to every tiddler put it inside a $list widget. However the filter on the list widget can also test a condition and only if it returns something. the inside is “displayed”.
*You should be able to transclude a full if/else structure from one tiddler into another.

I’d be very surprised if there were, although, to be fair, TiddlyWiki regularly surprises me with its abilities

Can you explain a bit more what you’re trying to do? We might be able to offer alternatives.

I’d like to do something along the lines of:

<%if [<somevariable>match{!!somefield}] %>
stuff

<$list filter="[tag[sometag]]">
<%elseif [<somevariable>match{!!somefield-on-taggedtiddler}] %>
{{taggedtiddler!!text}}
</$list>

<%else%>
<%endif%>

but this doesn’t work. @TW_Tones I can’t transclude just an <%elseif or $list <%elseifs inside of an <%if. I want to be able to add <%elseifs inside an <%if by writing the necessary contents in tiddlers that get tagged “sometag” and then $list-ing them.

That’s not possible. The conditional syntax internally is a variation of the list-widget. elseif can not be created using list-widgets.

The conditional syntax is resolved at parsing time. The list-widget is resolved at rendering time. So that are 2 completely different processes.

If you have special logic, you will need to use nested list-widgets.

1 Like

Would something like this work?

<$list filter="tag[sometag]] :filter[get[somefield]match<somevariable>] +[first[]]">
  {{!!text}}
</$list>

It’s totally untested, of course, but it looks to be similar to what you’re trying to do.

follow Mario and Scots advice. sorry I am off line for a couple of days

IF this were possible (note that’s a very big “if”) you would use the $genesis widget. However, I seriously doubt that <% ... %> would be considered an “element or widget” in the context of how the $genesis works.

What does $genesis do? It let’s you programmatically and dynamically generate widgets (and HTML elements). Used together with Custom Widgets, it is very powerful, allowing you to create structures/components in your wikitext that mostly cannot be created any other way.

But even so, I find it very unlikely you can construct <% ... %> using $genesis. It’s not a widget, it’s “syntactic sugar” that itself generates list widgets.