- #ABSPATHS
- #ADD
- #ADJUSTDATE
- #APPEND
- #ARCHIVELIST
- #ASSIGN
- #BREAK
- #BYTES_LENGTH
- #CALC
- #COMMENT
- #CONTEXT
- #COUNT
- #CPATH
- #CQL
- #CRC32
- #CSCRIPT
- #DEBUG
- #ECHO
- #EDIT
- #ENUM
- #ERROR
- #EVAL
- #EXCEPTION
- #EXISTS
- #EXPLODE
- #FILE
- #FILESIZE
- #FOR
- #FOREACH
- #FORMAT
- #GET
- #GETCOOKIE
- #GETFILE
- #GETTYPE
- #GLOBAL
- #HEADER
- #IF
- #IMAGE
- #IMPLODE
- #INCLUDE
- #INSERT
- #LINK
- #LIST
- #LOCAL
- #LTRIM
- #NEW
- #NEWOBJECT
- #NODEPEND
- #NOOUTPUT
- #NOTE
- #OUTPUT
- #PATHBASE
- #PATHFROM
- #PATHTO
- #PATHTYPE
- #PERL
- #PHP
- #PHP_EXPORT
- #PLAINTEXT
- #REF
- #REGEXMATCH
- #REGEXREPLACE
- #REGEXSELECT
- #RETURN
- #RTRIM
- #SIZE
- #SOURCE
- #SQL
- #SQLDB
- #STRING_BYTES
- #STRLEN
- #STRPOS
- #STRRPOS
- #STRSTR
- #STRTOLOWER
- #STRTOUPPER
- #SUBSTR
- #TEXT
- #TRIM
- #WARNING
- #WHILE
cTemplate Reference
cTemplate is the COMAND template language used to produce web pages and related files. It is functionally similar to cScript, except that it is written inline with plain text and markup, such as HTML.
Here is an example of what cTemplate looks like:
#/ Bullet list of contact links.
#INSERT(Template,Header)
<ul>
#LIST(Contacts)
<li><a href="#LINK(Contact,ID=$ID)">$Name</a></li>
#ENDLIST
</ul>
#INSERT(Template,Footer)
Language
cTemplate provides features similar to other template languages, including variables and flow control (if/then conditions, loops and iterators). Variables and directives are mixed in with other text. This form is best when most of the content is not template and script code.
- Variables - A dollar sign ($) followed by a letter and zero or more letters, numbers or underscores will be interpreted as a variable. A variable represents a value. When cScript is processed, variables are replaced by their values. For example,
$FullName
. Variables can also be referenced like${FullName}
. - Directives - A hash symbol (#) followed by a valid directive will be interpreted as described in the cTemplate Directives section. For example,
#ASSIGN($A,1+2)
. - Escape Sequences - A pair of two-character sequences are used to produce text that might otherwise be interpreted as the start of a variable or statement. Two dollar signs ($$) will produce a single dollar sign ($). Two hash symbols (##) will produce a single hash symbol (#).
- Whitespace - Whitespace on the same line as a cTemplate directive with no other text will be ignored. In other words, any spaces and tabs before or after a cTemplate directive on its own line will not be output, as well as any trailing carriage return or newline.
- Text - All other text (and binary data) will pass through unprocessed. In other words, if the text is not interpreted as a variable, directive or escape sequence, it will be output as-is.
Mixing with cScript
Large scripts and template code can be more cleanly written as cScript inside a #CSCRIPT block:
#CSCRIPT
// Bullet list of contact links.
insert(Template,Header);
echo('<ul>');
list(Contacts) {
echo('<li><a href="'+link(Contact,'ID=$ID')+'">$Name</a></li>');
}
echo('</ul>');
insert(Template,Footer);
#ENDCSCRIPT
Security
cTemplate directives provide programmatic access to COMAND Repository content and features, typically without low-level access to the server. This enables end-users to author templates and procedures without compromising server security. cTemplate features can be further restricted to "read-only" functionality, eliminating the ability to update the repository. Or, unrestricted features can be enabled to allow low-level access to the server in trusted code environments.