webCOMAND

#CSCRIPT

Evaluate a block containing cScript.  In other words, switch from cTemplate mode, which is best for templates where variables and statements are mixed in with output (statements start with # and are in all uppercase), to cScript, which is best for scripting where echo() is required for output and statements don't start with #, are in lowercase and end with a semi-colon.

Prototype

#CSCRIPT ... #ENDCSCRIPT
#{ ... }

Return

If a return is encountered in the cScript, the corresponding value will be returned.  Otherwise, a string containing any output from echo() will be returned.

Example

#CSCRIPT
    // embedded regular cScript inside cTemplate
    $contacts = cql('FROM Contacts ORDER BY LastName');
    list($contacts) {
        echo($FirstName + ' ' + $LastName + '\n');
    }
#ENDCSCRIPT

Example using Shorthand

#{
    // embedded regular cScript inside cTemplate
    $contacts = cql('FROM Contacts ORDER BY LastName');
    list($contacts) {
        echo($FirstName + ' ' + $LastName + '\n');
    }
}

Example using Shorthand and Return

#{
    // embedded regular cScript inside cTemplate
    $result = '';
    $contacts = cql('FROM Contacts ORDER BY LastName');
    list($contacts) {
        $result += $FirstName + ' ' + $LastName + '\n';
    }
    return $result;
}

Related

#EVAL, #PERL, #PHP