I have raised some technical Questions at the end I hope the developers can assist with;
Would there be a way for us to reference the result of the filter to use in the content? answered below, use<<condition>>
The reason I ask is if the result of the filter was available in a variable it could be used in some cases to construct the result, allowing for interesting abraviated code opportunities?
Keep in mind the if/else/elsif structure could be inside a list, and handle a case structure for all listed tiddlers.
Is there a way to use filters with multiple runs in them (Yes via a function?) but how about inline.
For example we may want the Ifcondition to be true if/:else/:else/:else eg one of 4 values.
Yet to test but could we just add quotes to the filter?
Or other versions like the filter transforms the value somehow, then tests the value for validity and inside the if/then/else displays the result, no need for a seperate variable.
With smart filters some quite sopisticated algorithiums could be developed with subsequnt filters using the output of previouse ones.
But going back to the docs, as Jeremy quoted them, else is not if or elseif. Plus, the result of your filter is blank. I think you’re going to need to provide a detectable result somehow.
One of the advantages of <$if> is that transcluded filters work, as do direct references to variables/fields. Plus, it provides a not attribute.
I’m a little concerned now that the new syntax may require a little more fancy footwork than I’d originally prepared for.
If you look at the new structure you will note only if and elseif actually permit a filter, and they test a condition.
Jeremy suggested the result of the filter was available in the condition field, as I think you @CodaCoder have pointed out only, in the if statement, not in the else statement because the else is only blank when the condition is false.
This suggests a usage guidance;
Else is “performed” only if the condition is empty,
If you want to make the result of the condition available in subsequent steps (ie; condition can have more than one possible value) then you can make use of the <<condition>> variable only inside the if statement.
Now I will need to test the following;
the ifelse condition result is available inside - correct
Can I pass a value to a nested item?
To explore this further, notice here I use [true[]] and [!true[]] if true, the result is the current tiddler which is useful.
The ifelse condition result is available inside - correct
<% if [!true[]] %>
a is <<condition>>
<% elseif [!true[]] %>
b is <<condition>>
<% elseif [!true[]] %>
c is <<condition>>
<% else %>
d is "<<condition>>" thus condition false
<% endif %>
Note “true” need not / should not, be define or a field.
I continue to explore but will add further content to the version in the Discussion Forum.
Sorry, Tones, I don’t follow that block of code at all:
Why are you negating a non-existant filter op, true[] ?
two identical elseif clauses makes no sense. Even if the clause (test) was valid, once the first elseif succeeds, the rest of the block (all subsequent elseifs and any else clause) will be skipped.
What you have there, since the if clause is always false, is a way to ensure an else block succeeds.
Perhaps. I’d prefer…
The first clause returning a non-empty result, succeeds. Failing that, the else clause, if present.
Also, I think you’re wrestling with scope with regards to <<condition>>. This variable exists throughout and within the clause that succeeds and nowhere… uh… else Which means…
all the way upto the closing `<% endif %> if there are no intervening clauses.
Otherwise, within the elseif clause that succeeds, if present
And I think <<condition>> might be a poor name-choice. I mean, it does represent the condition that succeeded, but it is not in itself a condition.
I did not disagree with you, nor negate your statement, I only clarified for any reader in the future. They may go looking for how I named the variable. If you want to challenge it, a reasonable case, perhaps visit github
If we consider your mention of it and my stating it is a dev issue, someone in the dev team may read and consider it. I am not responsible for addressing everyone else’s comments, but I did briefly. If this is important to you its up to you.
This thread was initiated by me to get answers, not give answers.
I am happy for you t0 raise this in this thread but I would urge you to manage the emphasis and importance you have for this, not expect me to.
Never the less “result” or “condition-result” may be a better variable name.