Inherit compat flag for partials

This commit is contained in:
kpdecker
2014-08-13 22:33:14 -05:00
parent d95725d5fd
commit 0edce6e1d1
3 changed files with 15 additions and 3 deletions
@@ -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) {
+2 -2
View File
@@ -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];
}
+9
View File
@@ -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 ');
});
});
});