Allow passing depths to _child

This commit is contained in:
kpdecker
2014-08-25 00:32:57 -05:00
parent 477a26913a
commit 501a640330
3 changed files with 15 additions and 8 deletions
+9 -2
View File
@@ -39,18 +39,25 @@ describe('runtime', function() {
return;
}
it('should throw for depthed methods', function() {
it('should throw for depthed methods without depths', function() {
shouldThrow(function() {
var template = Handlebars.compile('{{#foo}}{{../bar}}{{/foo}}');
// Calling twice to hit the non-compiled case.
template._setup({});
template._setup({});
template._child(1);
}, Error, '_child can not be used with depthed templates');
}, Error, 'must pass parent depths');
});
it('should expose child template', function() {
var template = Handlebars.compile('{{#foo}}bar{{/foo}}');
// Calling twice to hit the non-compiled case.
equal(template._child(1)(), 'bar');
equal(template._child(1)(), 'bar');
});
it('should render depthed content', function() {
var template = Handlebars.compile('{{#foo}}{{../bar}}{{/foo}}');
// Calling twice to hit the non-compiled case.
equal(template._child(1, undefined, [{bar: 'baz'}])(), 'baz');
});
});
});