Rendering models in tables produces different results than an equivalent observe #202

Closed
daffl opened this Issue Dec 10, 2012 · 0 comments

Projects

None yet

1 participant

@daffl

The following test renders

<table><tbody><tbody><tr></tr></tbody></tbody></table>

instead of the expected

<table><tbody><tr></tr></tbody></table>
test("Model Test", function() {
    var renderer = can.view.mustache('<table>{{#data}}<tbody>{{#rows}}<tr></tr>{{/rows}}</tbody>{{/data}}</table>');
    var div = document.createElement('div');
    var dom = renderer({
        data : new can.Model({
            rows: [{ name : 'first' }]
        })
    });
    div.appendChild(dom);
    var expected = "<table><tbody><tr></tr></tbody></table>";
    same(div.innerHTML, expected);
});

Setting the data to a can.Observe renders the expected output as well as changing the template to

<table><tbody>{{#data}}{{#rows}}<tr></tr>{{/rows}}{{/data}}</tbody></table>

Or

<table><tbody>{{#data.rows}}<tr></tr>{{/data.rows}}</tbody></table>
@daffl daffl closed this in 6d1a372 Dec 10, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment