coar 97/05/29 05:00:09
Modified: htdocs/manual/mod mod_include.html Log: Enhanced documentation of variable substitution, and moved out the `flow control' section to its own. (PR#545) Revision Changes Path 1.12 +61 -43 apache/htdocs/manual/mod/mod_include.html Index: mod_include.html =================================================================== RCS file: /export/home/cvs/apache/htdocs/manual/mod/mod_include.html,v retrieving revision 1.11 retrieving revision 1.12 diff -C3 -r1.11 -r1.12 *** mod_include.html 1997/05/18 18:55:04 1.11 --- mod_include.html 1997/05/29 12:00:07 1.12 *************** *** 52,62 **** as SGML comments. A command has the syntax: <blockquote><code> ! <!--#</code><em>element attribute=value attribute=value ...</em> <code>--> </code></blockquote> The value will often be enclosed in double quotes; many commands only allow ! a single attribute-value pair. <p> The allowed elements are:<p> --- 52,65 ---- as SGML comments. A command has the syntax: <blockquote><code> ! <!--#</code><em>element attribute=value attribute=value ...</em> ! <code> --> </code></blockquote> The value will often be enclosed in double quotes; many commands only allow ! a single attribute-value pair. Note that the comment terminator ! (<SAMP>--></SAMP>) should be preceded by whitespace to ensure that it ! isn't considered part of an SSI token. <p> The allowed elements are:<p> *************** *** 184,197 **** <dd>The value to give a variable. </dl> For example: ! <CODE><!--#set var="category" value="help"--></CODE> <dd>Apache 1.2 and above. </dl> ! <h2>Include variables</h2> ! In addition to the variables in the standard CGI environment, these are available for the <code>echo</code> command, for <code>if</code> and <code>elif</code>, and to any program invoked by the document. <dl> <dt>DATE_GMT --- 187,202 ---- <dd>The value to give a variable. </dl> For example: ! <CODE><!--#set var="category" value="help" --></CODE> <dd>Apache 1.2 and above. </dl> ! <h2>Include Variables</h2> ! In addition to the variables in the standard CGI environment, these are ! available for the <code>echo</code> command, for <code>if</code> and ! <code>elif</code>, and to any program invoked by the document. <dl> <dt>DATE_GMT *************** *** 210,215 **** --- 215,265 ---- </dl> <p> + <H2>Variable Substitution</H2> + <P> Variable substitution is done within quoted strings in most cases + where they may reasonably occur as an argument to an SSI directive. + This includes the + <SAMP>config</SAMP>, + <SAMP>exec</SAMP>, + <SAMP>flastmod</SAMP>, + <SAMP>fsize</SAMP>, + <SAMP>include</SAMP>, and + <SAMP>set</SAMP> + directives, as well as the arguments to conditional operators. + You can insert a literal dollar sign into the string using backslash + quoting: + + <PRE> + <!--#if expr="$a = \$test" --> + </PRE> + + <P> If a variable reference needs to be substituted in the middle of a + character sequence that might otherwise be considered a valid + identifier in its own right, it can be disambiguated by enclosing + the reference in braces, <EM>à la</EM> shell substitution: + + <PRE> + <!--#set var="Zed" value="${REMOTE_HOST}_${REQUEST_METHOD}" --> + </PRE> + + <P> This will result in the <SAMP>Zed</SAMP> variable being set to + "<SAMP>X_Y</SAMP>" if <SAMP>REMOTE_HOST</SAMP> is + "<SAMP>X</SAMP>" and <SAMP>REQUEST_METHOD</SAMP> is + "<SAMP>Y</SAMP>". + + <P> 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: + <PRE> + <!--#if expr="\"$DOCUMENT_URI\" = \"/foo/file.html\"" --> + in foo + <!--#elif expr="\"$DOCUMENT_URI\" = \"/bar/file.html\"" --> + in bar + <!--#else --> + in neither + <!--#endif --> + </PRE> + <H2>Flow Control Elements</H2> These are available in Apache 1.2 and above. The basic flow control *************** *** 256,267 **** <DT>! <I>test_condition</I> <DD>true if <I>test_condition</I> is false <DT><I>test_condition1</I> && <I>test_condition2</I> ! <DD>true if both <I>test_condition1</I> and <I>test_condition2</I> are true <DT><I>test_condition1</I> || <I>test_condition2</I> ! <DD>true if either <I>test_condition1</I> or <I>test_condition2</I> is true </DL> ! <P> "<I>=</I>" and "<I>!=</I>" bind more tightly than "<I>&&</I>" and "<I>||</I>". "<I>!</I>" binds most tightly. Thus, the following are equivalent: <PRE> --- 306,320 ---- <DT>! <I>test_condition</I> <DD>true if <I>test_condition</I> is false <DT><I>test_condition1</I> && <I>test_condition2</I> ! <DD>true if both <I>test_condition1</I> and ! <I>test_condition2</I> are true <DT><I>test_condition1</I> || <I>test_condition2</I> ! <DD>true if either <I>test_condition1</I> or ! <I>test_condition2</I> is true </DL> ! <P> "<I>=</I>" and "<I>!=</I>" bind more tightly than "<I>&&</I>" and ! "<I>||</I>". "<I>!</I>" binds most tightly. Thus, the following are equivalent: <PRE> *************** *** 281,320 **** <I>'string1 string2'</I> results in <I>string1 string2</I> </PRE> - <P> Variable substitution is done within quoted strings. You can put - a dollar sign into the string using backslash quoting: - - <PRE> - <!--#if expr="$a = \$test" --> - </PRE> - - <P> If a variable reference needs to be substituted in the middle of a - string, it can be done by enclosing the reference in braces, - <EM>á la</EM> shell substitution: - - <PRE> - <!--#set var="Zed" value="${REMOTE_HOST}_${REQUEST_METHOD}" --> - </PRE> - - <P> will result in the <SAMP>Zed</SAMP> variable being set to - "<SAMP>X_Y</SAMP>" if <SAMP>REMOTE_HOST</SAMP> is - "<SAMP>X</SAMP>" and <SAMP>REQUEST_METHOD</SAMP> is - "<SAMP>Y</SAMP>". - - <P> 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: - <PRE> - <!--#if expr="\"$DOCUMENT_URI\" = \"/foo/file.html\""--> - in foo - <!--#elif expr="\"$DOCUMENT_URI\" = \"/bar/file.html\""--> - in bar - <!--#else --> - in neither - <!--#endif --> - </PRE> - - <hr> <h2>Directives</h2> <ul> --- 334,339 ---- *************** *** 357,360 **** <!--#include virtual="footer.html" --> </BODY> </HTML> - --- 376,378 ----