CanJS视图返回@@!!@@if视图包含HTML表

CanJS view return @@!!@@ if view contain HTML table

本文关键字:视图 HTML 包含 @@if CanJS 返回      更新时间:2023-09-26

我正在使用http://canjs.com/Chromium 28.0.1500.71的持续版本(开发者版本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>

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

看起来这是CanJS中的一个bug。我可以通过将整个模板包装在另一个元素中来绕过它:

<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>

我给他们留下了一条关于一个bug的评论,这个bug看起来是同一个问题。