|
Conditional BlocksAn if-else structure looks like this: <if condition> Some HTML... </if> Or like this: <if condition> Some HTML... <else> Some other HTML... </if> Or like this: <if condition> Some HTML... <elseif condition2> Some other HTML... <else> Yet some more HTML.... </if> Note that you can have an arbitrary number of "elseif" blocks. The <if !(color == "blue" || color == "violet")> You have an unusual favorite color. </if> <if foo && (!(bar || baz) || elephant)> Tweedledee. </if> Since undefined, null, and empty values evaluate to false, it is convenient to use idioms like the following: <if error> <p>Your request cannot be processed because of the following error:<br> ${error} <else> (display results...) </if> Since undefined, null, and empty values are considered equal, the
following two statements are equivalent, whether <if foo> ... </if> <if foo != ""> ... </if> |
|