Inherit compat flag for partials
This commit is contained in:
@@ -123,7 +123,10 @@ JavaScriptCompiler.prototype = {
|
||||
ret.useData = true;
|
||||
}
|
||||
if (this.useDepths) {
|
||||
ret.depths = true;
|
||||
ret.useDepths = true;
|
||||
}
|
||||
if (this.options.compat) {
|
||||
ret.compat = true;
|
||||
}
|
||||
|
||||
if (!asObject) {
|
||||
|
||||
@@ -40,7 +40,7 @@ export function template(templateSpec, env) {
|
||||
|
||||
if (result == null && env.compile) {
|
||||
var options = { helpers: helpers, partials: partials, data: data };
|
||||
partials[name] = env.compile(partial, { data: data !== undefined }, env);
|
||||
partials[name] = env.compile(partial, { data: data !== undefined, compat: templateSpec.compat }, env);
|
||||
result = partials[name](context, options);
|
||||
}
|
||||
if (result != null) {
|
||||
@@ -125,7 +125,7 @@ export function template(templateSpec, env) {
|
||||
data = initData(context, data);
|
||||
}
|
||||
var depths;
|
||||
if (templateSpec.depths) {
|
||||
if (templateSpec.useDepths) {
|
||||
depths = [context];
|
||||
}
|
||||
|
||||
|
||||
@@ -155,4 +155,13 @@ describe('partials', function() {
|
||||
"Dudes:\n Yehuda\n http://yehuda!\n Alan\n http://alan!\n");
|
||||
});
|
||||
});
|
||||
|
||||
describe('compat mode', function() {
|
||||
it('partials inherit compat', function() {
|
||||
var string = 'Dudes: {{> dude}}';
|
||||
var partial = '{{#dudes}}{{name}} ({{url}}) {{root}} {{/dudes}}';
|
||||
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 ');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user