An if-else structure looks like this:
<if condition> Some HTML... </if>
Or like this:
<if condition> Some HTML... <else> Some other HTML... </if>
The condition should be a boolean expression. For example:
<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 foo is defined or not:
<if foo> ... </if> <if foo != ""> ... </if>
Previous: Lists | Next: Switch-Case |