<!--#if expr="test_condition" -->
do what's here
<!--#elif expr="test_condition" -->
do this instead
<!--#else -->
do this one
<!--#endif -->
These so-called flow-control elements allow you to make documents display differently depending on the variable (such as which browser is being used or the time of day or whatever).
The "test condition" is evaluated by Apache and, if it is true, the code following it is executed (if there are XSSI statements following it) or printed (if text/HTML follows it). Test conditions can take various forms, which are detailed in the Apache docs.
For example, if the variable "election" is set to the value "rigged," <!--#if expr="$election = rigged" --> will evaluate as true, but <!--#if expr="$election = legit" --> will evaluate as false. One useful way of writing this code is to use forward slashes around the string to be matched. These tell Apache to try to match the string as a regular expression. In our example, <!--#if expr="$election = /rig/" --> would match whether "election" was set to "rigged" or "righteous" or "rigmarole."
This command (the "I" in XSSI) inserts the contents of another file into the current file. At HotWired, we typically name fragments (files that are not complete HTML files) with the .htmlf extension. It's OK to include .html files, but be careful not to end up with a document that has multiple <html>, <head>, and <body> tags. For a complete how-to on server-side includes, check Liz's article.
<!--#set var="somevariable" value="the_value" -->
This sets a variable. See the next page for more on XSSI variables.
next page»