ASP style
ASP-style templates use <% ... %> delimiters and allow you to write full JavaScript code inside
the template. This gives you the most control over the output
Select render mode ASP style to use only this style, or Comment, Curly, ASP to combine it with other styles.
Output expression
Use <%= expression %> to evaluate an expression and output the result:
<p><%= $request.subject %></p>
Code blocks
Use <% ... %> to write JavaScript code that does not produce output directly,
for example for conditionals and loops (explained below):
<% if ($request.notes && $request.notes.length > 0) { %>
<p>This request has <%= $request.notes.length %> notes.</p>
<% } %>
Control flow
Since the code blocks are full JavaScript, you can use any control flow structure:
Conditionals
<% if ($request.status === "completed") { %>
<p>This request is completed.</p>
<% } else { %>
<p>This request is still in progress.</p>
<% } %>
For loops
<table>
<% for (let note of $request.notes) { %>
<tr>
<td><%= note.person.name %></td>
<td><%= note.text %></td>
</tr>
<% } %>
</table>
While loops
<% let i = 0; %>
<% while (i < items.length) { %>
<p><%= items[i].name %></p>
<% i++; } %>
Template literals
You can use JavaScript template literals with ${variable} syntax inside code blocks:
<% let message = `Hello ${$request.requested_by.name}`; %>
<p><%= message %></p>
Available functions
Inside ASP-style templates, you can call any function available to the script. This includes
formatting functions like formatDateTime and formatNumber:
<table class="notes">
<% for (let item of $request.notes) { %>
<tr>
<td><%= item.person.name %></td>
<td><%= formatDateTime(item.created_at, 'DD/MM/YY HH:mm z', 'Paris') %></td>
<td><%= formatNumber(item.price, '$0,0.00', 'de') %></td>
</tr>
<% } %>
</table>