Client Side Template

Client-side Templating Syntax

Description

The syntax used for client-side templates and examples. Templates can be used in Alpha Anywhere to merge JSON data into a desired format which then can be output in the form of HTML.

Discussion

See Client-side Templates to learn more about using template syntax.

Name
Description
\{\}

Escapes {} characters

{/* comment */}

Comments can be added to client-side templates using the {/* ... */} directive.

{condition:logical_expression}

Dynamically show or hide parts of a template.

{[count]}

Zero-based row number for the current row.

{[countOneBased]}

Used to number rows.

:date('formattingDefinition')

Formats date values

<escape<{some template code}>>

Escapes long strings of template characters

:escape

Escapes HTML elements in a field.

||

Specifies alternative text in a template when a data value is missing.

{(logicalExpression ? trueResult : falseResult)}

An inline if-else expression for creating a dynamic template.

:lowercase

Formats string values to make them lowercase.

:number('formattingDefinition')

Formats numeric values

[parent] Directive
{[root]}

Accesses the root object

{*@functionName}...{/*}

The arbitrary iterator allows you to iterate over dynamically created data.

{*else}

Code to execute when {*if logicalExpression} and {*elseif logicalExpression} conditions are not met.

{*elseif logicalExpression}

Evaluates if any additional javascript expressions are true/false after a {*if logicalExpression} command executes.

{*empty}{/*empty}

Displays alternative text when an array contains no entries.

{*endif}

Closes a conditional command.

{*ensure var 1,var 2,var 3}

Protects the existence of data variables.

{*footer}{/*footer}

Adds a footer to a template.

{*header}{/*header}

Adds a header to a template.

{*if <defined<var 1,var 2>>}...{*endif}

Executes a string or some data if a variable in the data set is defined.

{*if <undefined<var 1,var 2>>}...{*endif}

Lets you append strings in the template when variables are undefined.

{*if logicalExpression}

Defines a conditional section that evaluates if a javascript expression is true/false.

{*partial partialName}

Adds partial sections of data into the template.

{*root}{/*root}

Allows you to use headers and footers when the JSON data being passed in is an array.

{[temp]}

References data that has been stored in a global variable named 'temp'.

:uppercase

Formats string values to make them uppercase.

{[value]}

Loops over a JSON array and displays the element values.

See Also