- ⌂ Directives
- Directive Categories
cTemplate Directives
cTemplate directives are instructions that control the flow and output of a cTemplate as it is parsed.
Directives are denoted by a hash symbol (#) immediately followed by a directive name in all upper-case letters. For example:
#BREAK
Parameters
Most directives receive parameters, so the directive name must be followed by an open parenthesis, then zero or more comma-separated parameters, and a closing parenthesis. For example:
#CALC(1 + 2)
Depending on the directive, the following types of parameters may be accepted.
- Expression - A cTemplate Expression, including simple numbers and quoted strings.
- Regular Expression - A cTemplate Regular Expression.
Blocks
Some directives apply to a block of text. In those cases there is a start and end directive. For example:
#PLAINTEXT
Some text that will not be parsed.
#ENDPLAINTEXT
#FOREACH($array as $item)
${item.Title}
#ENDFOREACH
Directive Groups
cTemplate directives are organized into logical groups below and in the Table of Contents.
Variables
- Assign - #APPEND, #ASSIGN, #NEW
- Inspect - #COUNT, #EXISTS, #REF, #SIZE
- Scope - #GLOBAL, #LOCAL
- Date/Time - #ADJUSTDATE, #FORMAT
Content
Flow Control
- Conditions - #IF
- Loops - #LIST, #FOR, #EACH, #WHILE
- Escapes - #BREAK, #RETURN
- Interpret - #CALC, #CSCRIPT, #EVAL, #PERL, #PHP, #PLAINTEXT
- Comments - #COMMENT, #* ... *#, #/
Publishing
- Paths - #ABSPATHS, #PATHBASE, #PATHFROM, #PATHTO, #PATHTYPE
- Files - #LINK, #OUTPUT
- Suppression - #NODEPEND, #NOOUTPUT
- Logging - #NOTE, #WARNING, #ERROR, #DEBUG
Text
- Regular Expressions - #REGEXMATCH, #REGEXREPLACE and #REGEXSELECT
- Manipulation - #EXPLODE, #IMPLODE, #TEXT