使用底线模板在Backbone应用程序中呈现html时,出现SyntaxError:意外的EOF输出。这是我的模板:
<script type="text/template" id="shellmenu-template">
<div>
<p>menu template html will go here....</p>
<div class="menuButtonsContainer">
<% _.each(menu, function(menuItem){ %>
<button class="menuButton" id="<%= _.escape(menuItem.id)"><%= _.escape(menuItem.title) %></button>
<% }); %>
</div>
</div>
</script>
这部分特别是错误的:
id="<%= _.escape(menuItem.id)"
id属性是一个数字,这是menuItem对象:
dataPath: ""
helpType: "default"
id: 0
moduleName: "TestModule"
modulePath: "interaction/test/testmodule"
title: "Test Module Interaction"
我尝试在下划线模板代码中将id设置为字符串或将其设置为title属性,只是为了查看是否能以任何形状或形式使用测试用例,但到目前为止我还是很困惑。我有一个类似的模板,几乎做同样的事情,没有错误。
有什么想法让我愚蠢吗? :-)
最佳答案
好像您没有用<%=
关闭%>