Java Reference
In-Depth Information
{ name: "Go for a run" },
{ name: "Finish writing last chapter" },
{ name: "Phone bank" },
{ name: "Email Craig" }
]
Mustache implements “logic-less” templates that don't require any lines of logic to be ex-
plicitly written in JavaScript; instead, it is inferred from the context. This is how it would
iterate over the task array to display a list of tasks:
<ul>
{{#tasks}}
<li>{{name}}</li>
{{/task}}
</ul>
EJS uses more explicit JavaScript coding to achieve the same result. Each line of JavaScript
code is placed inside the special <% %> tags. If any values need to be evaluated, they are
placed inside <%= %> instead:
<ul>
<% tasks.forEach(function(task) { %>
<li><%= task.name %></li>
<% }); %>
</ul>
<% } %>>
Both of these templates would return this HTML code:
<ul>
<li>Get Milk</li>
<li>Go for a run</li>
<li>Finish writing last chapter</li>
<li>Phone bank</li>
<li>Email Craig</li>
</ul>
Search WWH ::




Custom Search