String expression directives are a collection of directives that control the output of a string expression.
Conditional Directives: {{#if}}, {{#else}}, and {{#endif}}
The {{#if}}, {{#else}}, and {{#endif}} conditional directives are used to all part of an expression to be conditionally included or suppressed from the expression output.
Syntax
{{#if (<condition>)}}
output
{{#else}}
output
{{#endif}}The <condition> variable is a valid Boolean expression.
Example
Your request was {{#if ({Form1}.Query("UACT1").Approved) }} approved {{#else}} declined {{#endif}}.
Iteration Directives: {{#for}} and {{#endfor}}
The {{#for}} and {{#endfor}} iteration directives are used to allow looping over Cora SeQuence.
Syntax
{{#for (<expression>) }}
output
{{#endfor}}The <expression> variable is any valid expression.
Example
<table>
{{#for ({Form1}.Query("Employees")) }}
<tr>
<td>{{: it.FirstName }}</td>
<td>{{: it.LastName }}</td>
</tr>
{{#endfor}}
</table>Text Directive: {{= }}
The {{= }} text directive is used to insert an expression evaluation result into the output, without applying encoding.
Syntax
{{= <expression> }}The <expression> variable is any valid expression.
Example (XML)
<root>
{{= "<element>1</element>" }}
</root>This expression returns the following output:
<root> <element>1</element> </root>
Text Directive: {{:}}
The {{:}} text directive is used to insert an expression evaluation result into the output, with first applying encoding.
Syntax
{{: <expression> }}
The <expression> variable is any valid expression.
Example (JSON)
{{#for ({Form1}.Query("Employees").First()) }}
{
Name: {{: it.Name }},
Email: {{: it.Email }},
BirthDay: {{: it.BirthDay }},
}
{{#endfor}}This expression returns the following output:
{
Name: "Chuck Norris",
Email: null,
LastUpdatedOn: "2016-06-15T13:45:30",
}Example (XML)
<department>{{: "Q&A" }}</department>This expression returns the following output:
<department>Q&A</department>Comment Directive: {{ * *}}
The comment directive allows you to add descriptive text to an expression.
Example
{{* This is a comment *}}
Expression Extension: #t
The #t expression extension provides additional information about an expression scope that is actively evaluating, specifically inside iteration directives. It exposes Cora SeQuence count and current element index properties.
Syntax
#t.Scope.Count
Returns the number of elements in the Cora SeQuence.
#t.Scope.Index
Returns the index of the element being iterated.
Example (JSON)
[
{{#for ({Form1}.Query("Products")) }}
{
Name: {{: ProductName }},
Category: {{: CategoryName }},
Price: {{: UnitPrice}}
} {{#if (#t.Scope.Index < #t.Scope.Count-1) }},{{#endif}}
{{#endfor}}
]