The UI language
The element ui:if
This element compares two values. If the result is true, the inner nodes are expanded and the condition code is set to true; otherwise the inner nodes are ignored, and the conditon code is set to false.
Level: Control structure
<!ELEMENT ui:if ANY> <!ATTLIST ui:if value1 CDATA #REQUIRED value2 CDATA #REQUIRED op CDATA "eq" >
Since WDialog-2.1 it is allowed to pass more than two operands to the comparison function, although there is not any application for this feature in WDialog itself. User-defined comparison functions may take advantage from this, however. Additional operands are passed as attributes value3, value4 and so on.
All page body elements may occur as sub elements.
The following operators are defined for ui:if:
Since WDialog-2.1, it is possible to call any function defined for bracket expressions. The function is called with two (or more) strings as arguments, and it is expected that the function returns a number indicating a boolean result: 0 is considered as the false value, and a non-zero number is considered as the true value. Currently, there aren't any other functions that would make sense to be called. The user may, however, define further functions.
The engine matching regular expressions is PCRE (Perl-compatible regular expressions), so the Perl syntax is used. The expressions are not anchored by default, so have to write ^ and $$ to force anchoring. ^ matches the beginning of the string, and $$ matches the end of the string ("single-line expressions"). Note that you have to write double dollars $$ because the dollar character is the escape character for template parameters.
Note that template parameters and bracket expressions within ui:if are unconditionally evaluated. See ui:cond for a discussion of the consequences of this fact.
<ui:if value1="$[n]" value2="1" op="int-gt"> The result has more than one solution: ... </ui:if>