是什么导致SyntaxError:下划线模板中出现意外的EOF错误?

Sam*_*ick 3 html javascript backbone.js underscore.js

当使用下划线模板在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>
Run Code Online (Sandbox Code Playgroud)

这部分特别错误: -

id="<%= _.escape(menuItem.id)"
Run Code Online (Sandbox Code Playgroud)

id属性是一个数字,这里是menuItem对象: -

dataPath: ""
helpType: "default"
id: 0
moduleName: "TestModule"
modulePath: "interaction/test/testmodule"
title: "Test Module Interaction"
Run Code Online (Sandbox Code Playgroud)

我已经尝试将id作为字符串或使其成为下划线模板代码中的title属性,只是为了看看我是否可以获得以任何形状或形式工作的测试用例但是到目前为止我很难过.我有一个类似的模板做了几乎没有错误的相同的事情.

我有什么想法引起这种愚蠢的想法吗?:-)

neo*_*neo 5

看起来你并没有关闭<%=%>