I have the following simple ejs template:
<% for (var i =0; i < 10; ++i) { %>
- <%- i %>
<% } %>
This renders the following:
- 0
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
How can I prevent ejs to create empty lines like these?
If possible I don't want to modify the result string but to tell ejs to not render these empty lines. How can I do that?
Trim-mode ('newline slurp') tag, trims following newline.
<% i -%> or <% -%> or <%= i -%> or <%- i -%>
All you need is the hypen.
In the Features section, there you can see this option:
- Newline-trim mode ('newline slurping') with
-%>
ending tag
Note that the new version of ejs
is maintained at mde/ejs
(not tj/ejs
anymore).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With