From a00c598266e17bb9081291b0009baa032246cfad Mon Sep 17 00:00:00 2001 From: Nils Knappmeier Date: Tue, 2 May 2017 22:30:59 +0200 Subject: [PATCH 1/3] Allow partial-blocks to be executed without "options" Closes #1341 If the @partial-block is called as parameter of a helper (like in {{#if @partial-block}}...{{/if}}, the partialBlockWrapper is executed without "options"-parameter. It should still work in without an error in such a case. --- lib/handlebars/runtime.js | 3 ++- spec/regressions.js | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/handlebars/runtime.js b/lib/handlebars/runtime.js index 1c084ce3d..3884e88c8 100644 --- a/lib/handlebars/runtime.js +++ b/lib/handlebars/runtime.js @@ -237,7 +237,8 @@ export function invokePartial(partial, context, options) { options.data = createFrame(options.data); // Wrapper function to get access to currentPartialBlock from the closure let fn = options.fn; - partialBlock = options.data['partial-block'] = function partialBlockWrapper(context, options) { + partialBlock = options.data['partial-block'] = function partialBlockWrapper(context, options = {}) { + // Restore the partial-block from the closure for the execution of the block // i.e. the part inside the block of the partial call. options.data = createFrame(options.data); diff --git a/spec/regressions.js b/spec/regressions.js index 6aca9088d..1678d80c1 100644 --- a/spec/regressions.js +++ b/spec/regressions.js @@ -282,4 +282,13 @@ describe('Regressions', function() { var string = '{{#each list}}{{#unless ./prop}}parent={{../value}} {{/unless}}{{/each}}'; shouldCompileTo(string, { value: 'parent', list: [ null, 'a'] }, 'parent=parent parent=parent ', ''); }); + + it('GH-1341: 4.0.7 release breaks {{#if @partial-block}} usage', function() { + var string = 'template {{>partial}} template'; + var partials = { + partialWithBlock: '{{#if @partial-block}} block {{> @partial-block}} block {{/if}}', + partial: '{{#> partialWithBlock}} partial {{/partialWithBlock}}' + }; + shouldCompileToWithPartials(string, [{}, {}, partials], true, 'template block partial block template'); + }); }); From 0e81f0a082dc970e97390795023db75b4c0faa59 Mon Sep 17 00:00:00 2001 From: Nils Knappmeier Date: Tue, 2 May 2017 22:55:08 +0200 Subject: [PATCH 2/3] Update release notes --- release-notes.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/release-notes.md b/release-notes.md index b4d3ec077..36bec7890 100644 --- a/release-notes.md +++ b/release-notes.md @@ -2,7 +2,15 @@ ## Development -[Commits](https://github.com/nknapp/handlebars.js/compare/v4.0.7...master) +[Commits](https://github.com/nknapp/handlebars.js/compare/v4.0.8...master) + +## v4.0.8 - May 2nd, 2017 +- [#1341](https://github.com/wycats/handlebars.js/issues/1341) [#1342](https://github.com/wycats/handlebars.js/issues/1342) Allow partial-blocks to be executed without "options" ([@nknapp](https://github.com/nknapp)) - a00c598 + +Compatibility notes: +- No breaking changes + +[Commits](https://github.com/nknapp/handlebars.js/compare/v4.0.7...v4.0.8) ## v4.0.7 - April 29th, 2017 - [#1319](https://github.com/wycats/handlebars.js/issues/1319): Fix context-stack when calling block-helpers on null values ([@nknapp](https://github.com/nknapp)) - c8f4b57 From fed5818876ec325b2b48a61395fe0089bdda05e8 Mon Sep 17 00:00:00 2001 From: Nils Knappmeier Date: Tue, 2 May 2017 22:55:44 +0200 Subject: [PATCH 3/3] v4.0.8 --- components/bower.json | 2 +- components/handlebars.js.nuspec | 2 +- lib/handlebars/base.js | 2 +- package.json | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/components/bower.json b/components/bower.json index 82d7ad1d0..55eca01a7 100644 --- a/components/bower.json +++ b/components/bower.json @@ -1,6 +1,6 @@ { "name": "handlebars", - "version": "4.0.7", + "version": "4.0.8", "main": "handlebars.js", "license": "MIT", "dependencies": {} diff --git a/components/handlebars.js.nuspec b/components/handlebars.js.nuspec index 1a785122f..8de339819 100644 --- a/components/handlebars.js.nuspec +++ b/components/handlebars.js.nuspec @@ -2,7 +2,7 @@ handlebars.js - 4.0.7 + 4.0.8 handlebars.js Authors https://github.com/wycats/handlebars.js/blob/master/LICENSE https://github.com/wycats/handlebars.js/ diff --git a/lib/handlebars/base.js b/lib/handlebars/base.js index 615661e23..a684797c9 100644 --- a/lib/handlebars/base.js +++ b/lib/handlebars/base.js @@ -4,7 +4,7 @@ import {registerDefaultHelpers} from './helpers'; import {registerDefaultDecorators} from './decorators'; import logger from './logger'; -export const VERSION = '4.0.7'; +export const VERSION = '4.0.8'; export const COMPILER_REVISION = 7; export const REVISION_CHANGES = { diff --git a/package.json b/package.json index c5bdba4fc..095917552 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "handlebars", "barename": "handlebars", - "version": "4.0.7", + "version": "4.0.8", "description": "Handlebars provides the power necessary to let you build semantic templates effectively with no frustration", "homepage": "http://www.handlebarsjs.com/", "keywords": [