<!--#set var="category" value="help" -->
if
element works like an
if statement in a programming language. The test condition
is evaluated and if the result is true, then the text until
the next elif
, else
.
or endif
element is included in the
output stream.
The elif
or else
statements are used if the original test_condition is false.
These elements are optional. Note that the first
true statement is used, and else
is always true (it does NOT take an expr
).
The endif
element ends the
if
element and is required.
test_condition can be any valid REXX statement. In addition, the following Apache (C) style comparions are also supported:
- string
- true if string
is not empty- string1 = string2
- Compare string1 with string 2.
- string1 != string2
- Compare string1 with string 2, TRUE if not equal.
- ( test_condition )
- true if test_condition is true
- ! test_condition
- true if test_condition is false
- test_condition1 && test_condition2
- true if both test_condition1 and test_condition2 are true
- test_condition1 || test_condition2
- true if either test_condition1 or test_condition2 is true
"=" binds more tightly than "&&" and "||". "!" binds most tightly. Thus, the following are equivalent:
<!--#if expr="$a = test1 && $b = test2" --> <!--#if expr="($a = test1) && ($b = test2)" -->
#set variables are used as textual substitutions within quoted. This substituion is performed where they may reasonably occur as an argument to an SSI directive. This includes the config, exec, flastmod, fsize, include, and set directives, as well as the arguments to conditional operators.
Notes:
EXAMPLE: the below example will print "in foo" if the DOCUMENT_URI is /foo/file.html, "in bar" if it is /bar/file.html and "in neither" otherwise:<!--#if expr="\"$DOCUMENT_URI\" = \"/foo/file.html\"" --> in foo <!--#elif expr="\"$DOCUMENT_URI\" = \"/bar/file.html\"" --> in bar <!--#else --> in neither <!--#endif -->Need more information on the Apache XSSI syntax?