防止EJS中的空行循环 [英] Prevent empty lines in ejs for loops
本文介绍了防止EJS中的空行循环的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下简单的ejs模板:
I have the following simple ejs template:
<% for (var i =0; i < 10; ++i) { %>
- <%- i %>
<% } %>
这将呈现以下内容:
- 0
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
如何防止ejs创建像这样的空行?
How can I prevent ejs to create empty lines like these?
如果可能的话,我不想修改结果字符串,而是告诉ejs不要渲染这些空行。我该怎么做?
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?
推荐答案
修剪模式('newline slurp')标记会在换行符后进行修饰。
Trim-mode ('newline slurp') tag, trims following newline.
<% i -%> or <% -%> or <%= i -%> or <%- i -%>
您需要的只是连字符。
在功能部分中,您可以看到以下选项:
In the Features section, there you can see this option:
- 以
-%>结尾的换行模式('newline slurping')标签
- Newline-trim mode ('newline slurping') with
-%>
ending tag
请注意, ejs $ c $的新版本c>保持在
mde / ejs
(不是 tj / ejs
不再。)
Note that the new version of ejs
is maintained at mde/ejs
(not tj/ejs
anymore).
这篇关于防止EJS中的空行循环的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文