diff options
author | kpdecker <kpdecker@gmail.com> | 2014-08-13 22:33:14 -0500 |
---|---|---|
committer | kpdecker <kpdecker@gmail.com> | 2014-08-14 00:29:25 -0500 |
commit | 0edce6e1d1555cfbe0c55908261fc304a145f1a1 (patch) | |
tree | a9bc592ed7ddbc71ef42e640d4065dcb533c3fd0 | |
parent | d95725d5fd57636078583791705cfa814bdf2258 (diff) | |
download | handlebars.js-0edce6e1d1555cfbe0c55908261fc304a145f1a1.zip handlebars.js-0edce6e1d1555cfbe0c55908261fc304a145f1a1.tar.gz handlebars.js-0edce6e1d1555cfbe0c55908261fc304a145f1a1.tar.bz2 |
Inherit compat flag for partials
-rw-r--r-- | lib/handlebars/compiler/javascript-compiler.js | 5 | ||||
-rw-r--r-- | lib/handlebars/runtime.js | 4 | ||||
-rw-r--r-- | spec/partials.js | 9 |
3 files changed, 15 insertions, 3 deletions
diff --git a/lib/handlebars/compiler/javascript-compiler.js b/lib/handlebars/compiler/javascript-compiler.js index b9b858d..a8544d5 100644 --- a/lib/handlebars/compiler/javascript-compiler.js +++ b/lib/handlebars/compiler/javascript-compiler.js @@ -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) { diff --git a/lib/handlebars/runtime.js b/lib/handlebars/runtime.js index ec54f53..de6ea1b 100644 --- a/lib/handlebars/runtime.js +++ b/lib/handlebars/runtime.js @@ -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]; } diff --git a/spec/partials.js b/spec/partials.js index 816fd1e..9c8fdbc 100644 --- a/spec/partials.js +++ b/spec/partials.js @@ -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 '); + }); + }); }); |