Add a test case for the math helper and add else blocks to the select test.
This commit is contained in:
@@ -7,6 +7,10 @@ Early termination
|
||||
|
||||
Comparisons are done in-order and only the first matching comparison (eq/ne/gt/gte/lt/lte) is evaluated. All other non-comparison elements inside the select tag are still rendered normally.
|
||||
|
||||
Matching is terminated even if the first matching comparison has its own key.
|
||||
|
||||
Else blocks are rendered until the first matching comparison but else blocks after that are not rendered.
|
||||
|
||||
Default vs none
|
||||
---------------
|
||||
Default was deprecated as of dust 1.6.0 and no longer does anything. It was deprecated because it was essentially the same as none except that there could only be one per select block and it had to be placed after all the other conditions to make sure they were all false. None is more flexible.
|
||||
|
||||
@@ -101,6 +101,20 @@ Early termination stand-alone comparison{~n}
|
||||
{/pet_names}
|
||||
{/select}{~n}
|
||||
|
||||
Early termination else block{~n}
|
||||
============================{~n}
|
||||
{@select key=pet}
|
||||
{@eq value="dog"}Lets name your pet rover{~n}{:else}Lets not name your pet rover{~n}{/eq}
|
||||
{@eq value="cat"}Lets name your pet fluffy{~n}{:else}Lets not name your pet fluffy{~n}{/eq}
|
||||
{@eq value="cat"}Lets name your pet whiskers{~n}{:else}Lets not name your pet whiskers{~n}{/eq}
|
||||
{@eq value="lizard"}Lets name your pet dave{~n}{:else}Lets not name your pet dave{~n}{/eq}
|
||||
{@any}{person} has a pet!{~n}{/any}
|
||||
text not inside a comparison{~n}
|
||||
{#pet_names}
|
||||
If your pet was a {type} we'd name it {pet_name}{~n}
|
||||
{/pet_names}
|
||||
{/select}{~n}
|
||||
|
||||
@any alone{~n}
|
||||
=========={~n}
|
||||
{@any}{person} has a pet!{~n}{/any}
|
||||
|
||||
Reference in New Issue
Block a user