CanJS - issue #1235

{{#each}} within attribute value prints incorrectly

by prometh

HTML

<script src="http://canjs.us/release/latest/can.jquery.js"></script>
<script src="http://canjs.us/release/latest/can.construct.proxy.js"></script>
<script src="http://canjs.us/release/latest/can.control.plugin.js"></script>
<script src="http://canjs.us/release/latest/can.view.modifiers.js"></script>
<script src="http://canjs.us/release/latest/can.construct.super.js"></script>
<script src="http://canjs.us/release/latest/can.object.js"></script>
<script src="http://canjs.us/release/latest/can.ejs.js"></script>
<script src="http://canjs.us/release/latest/can.map.attributes.js"></script>
<script src="http://canjs.us/release/latest/can.map.backup.js"></script>
<script src="http://canjs.us/release/latest/can.map.delegate.js"></script>
<script src="http://canjs.us/release/latest/can.map.setter.js"></script>
<script src="http://canjs.us/release/latest/can.map.validations.js"></script>
<script src="http://canjs.com/release/latest/can.fixture.js"></script>
<script src="http://canjs.com/release/latest/can.stache.js"></script>
<script id="comp-broken1" type="text/handlebars">
    <p title="{{#each list}}{{#if @index}},{{/if}}{{.}}{{/each}}">Hover over this for tooltip</p>
    <p><b>Tooltip <em>should</em> look like:</b> {{#each list}}{{#if @index}},{{/if}}{{.}}{{/each}}</p>
</script>

<script id="comp-broken2" type="text/handlebars">
    <p title="{{#each compute}}{{#if @index}},{{/if}}{{.}}{{/each}}">Hover over this for tooltip</p>
    <p><b>Tooltip <em>should</em> look like:</b> 1,2</p>
</script>

CSS

em {font-style:italic; font-weight:inherit}
p {border:1px solid silver; margin:1em}

JavaScript

can.Component.extend({
    tag: "comp-broken1",
    template: can.view("comp-broken1"),
    scope: { list:[1,2] }
});

can.Component.extend({
    tag: "comp-broken2",
    template: can.view("comp-broken2"),
    scope: {
        list: [1,2],
        compute: can.compute( function() {
            return this.attr("list").serialize();
        })
    }
});

can.append( can.$(document.body), can.stache("<h1>Broken 1 (can.stache)</h1><comp-broken1/>")() );
can.append( can.$(document.body), can.mustache("<h1>Broken 1 (can.mustache)</h1><comp-broken1/>")() );

can.append( can.$(document.body), can.stache("<hr/><h1>Broken 2 (can.stache)</h1><comp-broken2/>")() );
can.append( can.$(document.body), can.mustache("<h1>Broken 2 (can.mustache)</h1><comp-broken2/>")() );