This version is out of date, covering development as far as v4.2.5. It is maintained here only for inbound reference links from elsewhere. Jump to the current version of aTbRef. |
A Tinderbox Reference File : Export Codes : Export Codes - Full Listing : ^if( condition )^ |
^if( condition )^ |
^if( condition )^
Test if the condition is true, then includes everything from the ^if statement to the ^else^ or the ^endif^. If the else/endif mark-up is omitted the text following the closing ) bracket of the condition is returned. These are functionally the same:
Whilst the usual way to test for the existence of an object or group remains
^if(^exists(child)^)^
... the shorter test syntax
^if(^children^)^
works as well — i.e. if a note has any descendants, then ^children^ is true.
Note there is no 'else if' branching syntax; for such tests nest if statements.
From v 3.0.0, the export element ^if^ now accepts agent query expressions in the condition. For example,
^if(Name(tbx))^
...is true if the note's title contains the string "tbx",
^if(!Name(tbx))^
...is true if the note's title does not contain the string "tbx", and
^if(Width>5)^
...is true if the note's width exceeds 5.0
For the first two examples above the value matched can be an actual string or a regular expression (see more on this).
In the ^if^ condition, the agent query is always evaluated in the context of this note.
Also new from v3.0.0 is a slightly different if syntax: if(query){action list}else{action list}. This syntax can only be used internally in Actions and Rules. In such context, either if syntax may be used but the ^if version, with carets, is the only one that may be used in export templates.
Up: Conditional Mark-up | |
Previous: ^else^ | Next: ^not( condition )^ |
Licensed under Creative Commons Attribution-Noncommercial-Share Alike 3.0 License
[See aTbRef CC licence Attribution/Waiver info info]