Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Template literal notation uses the dollar sign and curly braces to signify a variable or an expression. For example:

Code Block
The current customer number is: ${

...

customerNumber}.
The customer name is: ${customerName.trim()}.

EJS Notation

EJS Syntax allows you to both control the instruction output and its flow. Use the <%- someOutput %> syntax to control the instruction output. Use the <% code %> to control the flow. Template literals can be used together with EJS syntax, if desired.

For example:

Code Block
The current customer number is: <%- customerNumber %>.
The customer name is: <%- ${customerName} %>.

<% if (opportunities.length > 0) { %>
The following is a list of customer opportunities:
<% for (let opportunity of opportunities) { %>
- <%- opportunity.description %>
<% } %>
<% } %>

...

Code Block
<%
const { customerNumber, customerName } = await call("get session data", { sessionId });
%>

The current customer number is: <%- customerNumber %>.
The customer name is: <%=- customerName %>.

In this instance, customerNumber and customerName are retrieved from server-side data by calling the "get session data" routine, while sessionId is an Instruction Variable sourced from the browser. This method effectively marries server-side capabilities with client-side interactions, allowing for a seamless and secure use of your data.