From 18ff80d4f99beec874295ad9bcbb50104728b300 Mon Sep 17 00:00:00 2001 From: Les Hill Date: Thu, 6 Dec 2012 21:45:16 -0800 Subject: [PATCH] Resolve possible lambdas for partials An ID passed to a partial might be a property or a lambda. We need to check for both when passing contexts into partials. --- lib/handlebars/compiler/compiler.js | 1 + spec/qunit_spec.js | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/lib/handlebars/compiler/compiler.js b/lib/handlebars/compiler/compiler.js index 7578dd2d7..68c6129b3 100644 --- a/lib/handlebars/compiler/compiler.js +++ b/lib/handlebars/compiler/compiler.js @@ -165,6 +165,7 @@ Handlebars.JavaScriptCompiler = function() {}; if(partial.context) { this.ID(partial.context); + this.opcode('resolvePossibleLambda'); } else { this.opcode('push', 'depth0'); } diff --git a/spec/qunit_spec.js b/spec/qunit_spec.js index 5c9425396..9208bbb58 100644 --- a/spec/qunit_spec.js +++ b/spec/qunit_spec.js @@ -482,6 +482,14 @@ test("partials with context", function() { "Partials can be passed a context"); }); +test("partials resolve context which is lambda", function() { + var string = "Path lambdas: {{>result lambda}}"; + var partial = "implemented for {{name}}"; + var hash = {lambda: function() { return {name: 'Handlebars'}}}; + shouldCompileToWithPartials(string, [hash, {}, {result: partial}], true, "Path lambdas: implemented for Handlebars", + "Partials can be passed a context"); +}); + test("partial in a partial", function() { var string = "Dudes: {{#dudes}}{{>dude}}{{/dudes}}"; var dude = "{{name}} {{> url}} ";