Fix partial handling with different context
This commit is contained in:
@@ -136,7 +136,7 @@ export function template(templateSpec, env) {
|
||||
blockParams = templateSpec.useBlockParams ? [] : undefined;
|
||||
if (templateSpec.useDepths) {
|
||||
if (options.depths) {
|
||||
depths = context !== options.depths[0] ? [context].concat(depths) : options.depths;
|
||||
depths = context !== options.depths[0] ? [context].concat(options.depths) : options.depths;
|
||||
} else {
|
||||
depths = [context];
|
||||
}
|
||||
|
||||
@@ -238,6 +238,12 @@ describe('partials', function() {
|
||||
var hash = {root: 'yes', dudes: [{name: 'Yehuda', url: 'http://yehuda'}, {name: 'Alan', url: 'http://alan'}]};
|
||||
shouldCompileToWithPartials(string, [hash, {}, {dude: partial}, true], true, 'Dudes: Yehuda (http://yehuda) yes Alan (http://alan) yes ');
|
||||
});
|
||||
it('partials can access parents with custom context', function() {
|
||||
var string = 'Dudes: {{#dudes}}{{> dude "test"}}{{/dudes}}';
|
||||
var partial = '{{name}} ({{url}}) {{root}} ';
|
||||
var hash = {root: 'yes', dudes: [{name: 'Yehuda', url: 'http://yehuda'}, {name: 'Alan', url: 'http://alan'}]};
|
||||
shouldCompileToWithPartials(string, [hash, {}, {dude: partial}, true], true, 'Dudes: Yehuda (http://yehuda) yes Alan (http://alan) yes ');
|
||||
});
|
||||
it('partials can access parents without data', function() {
|
||||
var string = 'Dudes: {{#dudes}}{{> dude}}{{/dudes}}';
|
||||
var partial = '{{name}} ({{url}}) {{root}} ';
|
||||
|
||||
Reference in New Issue
Block a user