Features of chtml

Date Stamping

<!--chtml date="xxx"-->
Expands into the date string specified by xxx. Format is the same as for htmldate. By default, the date used will be the date of the most recent file among the processed file and any included files.

Example:

<!--chtml date="%m/%d/%y"-->
for this file would expand to:

6/20/08

<!--chtml date="xxx" toponly-->
Force the date of the processed top-level file to be used.
<!--chtml date="xxx" allfiles-->
Force all included files to be taken into account for date processing.
<!--chtml options date=toponly-->
Assume a date command has toponly unless it explicitly has allfiles. Note all instances of this command in a file (and included files) are processed before any date commands, so given the code seqence:
<!--chtml date="%m/%d/%y"-->
<!--chtml options date=toponly-->
the date command will default to the toponly behavior.
<!--chtml options date=allfiles-->
Assume a date command has allfiles unless it explicitly has toponly. The processing order caveat of the previous command also applies here.
<!--chtml date="xxx" file="filename"-->
Causes the date of the file filename to be used. You can use a filename such as //webinfo/announce.html which will search the current DOCUMENT_PATH for the file. Note the order of the search is the reverse of how the http server searches for documents. In other words, on www.washington.edu, instead of searching in uw before world, chtml date statements will search world before uw.

Comments

<!--chtml cmt-->text<!--chtml /cmt-->
Any text between these two meta-markup tags will be removed. For example:
First sentence.
<!--chtml cmt-->
Second sentence.
<!--chtml /cmt-->
Third sentence.
would expand as:

First sentence. Third sentence.

Variables

<!--chtml set var="value"-->
<!--chtml set var-->value<!--chtml /set-->
Define variable var to have value value.
<!--chtml use var-->
Return value previously set for variable var. The contents of all variables are assumed to be the null string before being set.

Examples of using variables:

<!--chtml set home="University of Washington Home Page"-->
The <!--chtml use home--> was redesigned in June 1996.

would expand as:

The University of Washington Home Pagewas redesigned in June 1996.

An example of using the second form of setting variables:

<!--chtml set text-->complicated text which
can include "quoted" material and many lines of text, as well as
<B>HTML code</B>.<--chtml /set-->
chtml can also set <!--chtml use text-->

would expand as:

chtml can also set complicated text which can include "quoted" material and many lines of text, as well as HTML code.

The contents of the variables will have no chtml processing done to them, so if you use the second form, you can have no chtml commands between the chtml set and chtml /set statements.

Predefined Variables

Some variables are predefined by chtml, and can be used either with the chtml use command or in conditional statements.

Variable Contents Example value (for this document)
sourcefile Name of the file being used features.html
sourcedir Name of the directory for this file /www/world/webinfo/chtml/
sourceuri Non-host part of the URL /webinfo/chtml/features.html
servername Name of the server www.cac.washington.edu

Including Files

<!--chtml include "filename"-->
Replace statement with contents of filename. You can use a filename such as //webinfo/buttons.inc which will search the current DOCUMENT_PATH for the file. Note the order of the search is the reverse of how the http server searches for documents. In other words, on www.washington.edu, instead of searching in uw before world, chtml include statements will search world before uw.
<!--chtml include "filename" quoted-->
Same as the include statement above, but will quote the contents ("&" becomes "&amp;", "<" becomes "&lt;", and ">" becomes "&gt;"). Useful if you wish to show the HTML markup of a file. Note that because of the quoting, you cannot use chtml commands in a quoted include file.

Conditional Statements

<!--chtml if cond-->
	text
<!--chtml elseif cond-->
	text
<!--chtml else-->
	text
<!--chtml endif-->

Will display text depending on conditions. Defined conditions are:

var="xx" any variable is equal to xx
var=="xx" same as var="xx"
var!="xx" any variable is not equal to xx
var=~"xx" any variable matches the Perl regular expression xx
var!~"xx" any variable does not match the Perl regular expression xx

Anchor URLs

<!--chtml anchor optargs-->url<!--chtml /anchor-->
Replace with:

<A HREF="url" optargs>url</A>

For example:

<!--chtml anchor-->http://www.washington.edu/<!--chtml /anchor--> 

would expand as:

http://www.washington.edu/