From 231a8d7256d24c1a0287d67d393f06faa32751e8 Mon Sep 17 00:00:00 2001 From: kpdecker Date: Sat, 1 Aug 2015 16:29:45 -0500 Subject: Fix with operator in no @data mode --- lib/handlebars/base.js | 2 +- spec/builtins.js | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/handlebars/base.js b/lib/handlebars/base.js index c7dc081..756fb77 100644 --- a/lib/handlebars/base.js +++ b/lib/handlebars/base.js @@ -202,7 +202,7 @@ function registerDefaultHelpers(instance) { return fn(context, { data: data, - blockParams: Utils.blockParams([context], [data.contextPath]) + blockParams: Utils.blockParams([context], [data && data.contextPath]) }); } else { return options.inverse(this); diff --git a/spec/builtins.js b/spec/builtins.js index 9598743..e5d923f 100644 --- a/spec/builtins.js +++ b/spec/builtins.js @@ -51,6 +51,12 @@ describe('builtin helpers', function() { var string = '{{#with person as |foo|}}{{foo.first}} {{last}}{{/with}}'; shouldCompileTo(string, {person: {first: 'Alan', last: 'Johnson'}}, 'Alan Johnson'); }); + it('works when data is disabled', function() { + var template = CompilerContext.compile('{{#with person as |foo|}}{{foo.first}} {{last}}{{/with}}', {data: false}); + + var result = template({person: {first: 'Alan', last: 'Johnson'}}); + equals(result, 'Alan Johnson'); + }); }); describe('#each', function() { -- cgit v1.1