[SalesForce] Define a function in Guide Template Language

Documentation for Guide template language has an example of how to call a function, but nothing on how to define a new function. Any advice on this?

Tried:

Defining in a server-side JS block

    <script runat="server">
        var Something = function(){
            return "FOO!";
        }
    </script>
    <p>{{=Something()}}</p>

But breaks the page. If you have to ask for error codes, you haven't worked with this tool yet: the error reporting is even more useless than the documentation.

Best Answer

Guide Template Language is able to use AMPscript functions using simple tags and the = prefix. Guide will pass any parameters included in the inner text of the template to the specified function. Once completed, Guide replaces the template with the output of the function.

Currently Guide does not support user created functions like Handlebars.js does natively.

List of AMPscript functions that should be available within the Guide and follows the same parameters for usage.

Basic structure:

{{=function(parameter)}}

Example:

{{=Add(1,1)}} 

Displays the result of 2.

You must quote string and date literals. You can optionally quote numeric literals. You can include an ampersand (&) character or enclose the variable with single curly brackets ({}) to render the content as un-escaped within the function. Guide treats any string prefixed with an & character as a variable.

Related Topic