underscore.js 模板错误
我正在尝试将 .txt 文件加载到
,当 .txt 有这样的代码时<h1>Hello <%= name %></h1>
它工作正常,但是当我有一些像这样的代码时,
<select name="action_edit" id="task_action_edit">
<option value="none">None</option>
<%
foreach(actions as action) {
if(action['id'] == 2) {
%>
<option selected="selected" value="<%= action['id'] %>" action_abbr="<%= action['title'] %>">
<%= action['title'] %>
</option>
<%
} else {
%>
<option value="<%= action['id'] %>" action_abbr="<%= action['title'] %>">
<%= action['title'] %>
</option>
<%
}
}
%>
</select>
Firefox 会在我'时显示此错误我正在将此 .txt 代码加载到 div
missing ) after argument list
[Break On This Error] var __p=[],print=function(){__p.push.a... </select>');}return __p.join('');
underscore.js (line 779)
我做错了什么?
谢谢,
I'm trying to load .txt file to <div>
and when .txt have code like this
<h1>Hello <%= name %></h1>
It is working properly, but when I have some code like this
<select name="action_edit" id="task_action_edit">
<option value="none">None</option>
<%
foreach(actions as action) {
if(action['id'] == 2) {
%>
<option selected="selected" value="<%= action['id'] %>" action_abbr="<%= action['title'] %>">
<%= action['title'] %>
</option>
<%
} else {
%>
<option value="<%= action['id'] %>" action_abbr="<%= action['title'] %>">
<%= action['title'] %>
</option>
<%
}
}
%>
</select>
Firefox showing me this error when I'm loading this .txt code to div
missing ) after argument list
[Break On This Error] var __p=[],print=function(){__p.push.a... </select>');}return __p.join('');
underscore.js (line 779)
What I'm doing wrong?
Thanks,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Underscore 的模板在
<% ... %> 分隔符。 This:
不是 JavaScript,这可能会导致您看到的奇怪错误。也许您的意思是:
在您的模板中。
Underscore's templates use JavaScript inside the
<% ... %>
delimiters. This:is not JavaScript and that could lead to the odd error you're seeing. Maybe you mean:
in your template.