- ⌂ ctemplate
 - Static Methods
 
ctemplate::run_ctemplate()
Process cTemplate code and return the result as a string.
Prototype
string run_ctemplate(string $text, array $options = [])
Parameters
- text - cTemplate code to process.
 - options - Associative array of key/value pairs.  The following keys are supported.
	
- context - A cObject that represents the object this cTemplate will be processed within. In other words $this will reference the specified object, and it's fields will be made available as variables for direct access. params with the same key will take precedence.
 - log - The event log where processing events will be logged, including events produced by #NOTE() and similar directives.
 - modules - Optional array of modules that define the directives and features available to the cTemplate code when it is processed. For example, '\io_comand_repo\script\edit' will enable #ADD() and #EDIT() directives.
 - params - Associative array of key/value pairs to define variables that will be available to the cTemplate code when it is processed. The key is the variable and the value is a boolean, number, string or cObject (it's fields will be available using dot notation).
 - repo - The repository cTemplate directives will use when they need access to a repository. For example, where #CONTEXT() will look for matching objects.
 - title - The title to include in the event log to identify this process.
 - decode_html_entities - If TRUE, decode HTML Entities in $text into their UTF8 character equivalents. Useful if $text is coming from code in a Rich Text field. Default is FALSE.
 
 
Return
A string that contains the output from the processed cTemplate, or an empty string if no output or if a critical error occurred (errors will be included in the event log specified by the log option).
Example
<?php
require_once('/path/to/comand.php');
$code = '#CALC(1+2)';
$repo = \comand::repo();
$log = new \io_comand_log\log();
$result = \io_comand_script\ctemplate::run_ctemplate($code, [
    'repo' => $repo,
    'log' => $log
]);
// echo the result: 3
echo($result);
// if any events were logged, display them
if(count($log) > 0) {
    echo("<h1>Event Log</h1>\n");
    echo($log->as_html());
}
            				
        					
        
        				
webCOMAND Docs