Syntax:
#include [raw] FILENAME_EXPR #include [raw] source=STRING_EXPR
The #include
directive is used to include text from outside the
template definition. The text can come from an external file or from a
$placeholder
variable. When working with external files, Cheetah will
monitor for changes to the included file and update as necessary.
This example demonstrates its use with external files:
#include "includeFileName.txt"
And this example demonstrates use with $placeholder
variables:
#include source=$myParseText
$myParseText
will be parsed for Cheetah syntax. This is not
the same as simply placing the $placeholder tag ``$myParseText
'' in
the template definition. In the latter case, the value of $myParseText would
not be parsed.
By default, included text will be parsed for Cheetah tags. The argument
``raw
'' can be used to suppress the parsing.
#include raw "includeFileName.txt" #include raw source=$myParseText
Cheetah wraps each chunk of #include
text inside a nested
Template
object. Each nested template has a copy of the main
template's searchList. However, #set
variables are visible
across includes only if the defined using the #set global
keyword.
All directives must be balanced in the include file. That is, if you start
a #for
or #if
block inside the include, you must end it in
the same include. (This is unlike PHP, which allows unbalanced constructs
in include files.)