Skip to content

Commit

Permalink
Fix Mustache binding lists in helpers. Closes #438, closes #463. Big …
Browse files Browse the repository at this point in the history
…props to @azazel75.
  • Loading branch information
daffl committed Oct 12, 2013
1 parent 988ca2a commit 60a1e63
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 5 deletions.
30 changes: 26 additions & 4 deletions view/mustache/mustache_test.js
Expand Up @@ -2106,9 +2106,31 @@ test("support null and undefined as an argument", function(){
ok(arg1 === null);
ok(arg2 === undefined)
}
})


})
});
});

test("passing can.List to helper (#438)", function() {
var renderer = can.view.mustache('<ul><li {{helper438 observeList}}>observeList broken</li>' +
'<li {{helper438 array}}>plain arrays work</li></ul>')

can.Mustache.registerHelper('helper438', function(classnames) {
return function(el) {
el.innerHTML = 'Helper called';
};
});

var frag = renderer({
observeList: new can.List([ { test: 'first' }, { test: 'second' }]),
array: [ { test: 'first' }, { test: 'second' }]
});
var div = document.createElement('div');

div.appendChild(frag);

var ul = div.children[0];

equal(ul.children[0].innerHTML, 'Helper called', 'Helper called');
equal(ul.children[1].innerHTML, 'Helper called', 'Helper called');
});

})();
2 changes: 1 addition & 1 deletion view/render.js
Expand Up @@ -145,7 +145,7 @@ can.extend(can.view, {
}

// If we had no observes just return the value returned by func.
if(!compute.hasDependencies){
if(!compute.hasDependencies || typeof value === "function"){
unbind();
return (escape || status !== 0? contentEscape : contentText)(value, status === 0 && tag);
}
Expand Down

0 comments on commit 60a1e63

Please sign in to comment.