如果视图包含HTML表,CanJS视图返回@@ !! @@

时间:2013-08-16 16:05:06

标签: javascript canjs

我正在使用http://canjs.com/持续版本与Chromium 28.0.1500.71(Developer Build 28.0.1500.71-0ubuntu1.12.10.1)Ubuntu 12.10

例如,我有这个模板脚本:

<script type="text/ejs" id="sequenceDetail">
    <header><%= this.qname %></header>
    <% this.stories.each(function(story) { %>
    <div>Story ID: <%= story.id %>GStory ID: <%= story.gstoriesid %></div>
    <table>
        <tr>
            <td>Story ID:</td>
            <td>GStory ID:</td>
        </tr>
    </table>
    <% }); %>
</script>

这会给我发一句话:

<article>
    <header>Fun Fact Lab</header>
    @@!!@@
</article>

但如果我将模板更改为(删除表格):

<script type="text/ejs" id="sequenceDetail">
    <header><%= this.qname %></header>
    <% this.stories.each(function(story) { %>
    <div>Story ID: <%= story.id %>GStory ID: <%= story.gstoriesid %></div>
    <% }); %>
</script>

然后我会得到我想要的东西:

<header>Fun Fact Lab</header>
<div>Story ID: 517587GStory ID: 0</div>
<div>Story ID: 517588GStory ID: 0</div>
<div>Story ID: 517589GStory ID: 0</div>

这是这个lib的错误还是我的错误?

1 个答案:

答案 0 :(得分:0)

看起来这是CanJS中的一个错误。通过将整个模板包装在另一个元素中,我能够绕过它:

<script type="text/ejs" id="sequenceDetail">
<div>
    <header><%= this.qname %></header>
    <% this.stories.each(function(story) { %>
    <div>Story ID: <%= story.id %>GStory ID: <%= story.gstoriesid %></div>
    <% }); %>
</div>
</script>

I've left a comment对于他们来说,这个问题看起来像是同一个问题。