cScript Functions
All cTemplate Directives are available in cScript as functions, with the following additions and differences. It is also possible to create your own custom functions.
Additions
The following cScript functions do not have a Template equivelent.
- debug_echo()
- php($eval_string) - Evaluate string as PHP code and return result.
- php_export($expression) - Call's PHP var_export($expression, TRUE).
- regex_match($pattern,$subject) - Call PHP preg_match() and return if there was a match (TRUE or FALSE).
- regex_replace($pattern,$replacment,$subject) - Call PHP preg_replace().
- regex_select($pattern,$subject,$index=NULL) - Call PHP preg_match() and return the array of matches (if index=NULL) or a specific match (if index=n).
- variable_scope()
Underscores
Many cScript function names include underscores between words, while cTemplate typically does not. This is so that each form is more consistent with other template and scripting languages, and for backward-compatibility (cTemplate came long before cScript).
For example:
#PATHTYPE('Root')
...
#ENDPATHTYPE
becomes:
path_type('Root');
...
end_path_type();
Start and End Functions
Some cScript functions mark the start and end of a block of code, which looks a bit different than the same functionality in cTemplate.
For example:
#PATHTYPE('Root')
...
#ENDPATHTYPE
becomes:
path_type('Root');
...
end_path_type();