From 882cbb621c893bf41255f09db527f4beebcf545a Mon Sep 17 00:00:00 2001 From: Zack Date: Thu, 23 Dec 2021 21:00:56 -0500 Subject: [PATCH 1/2] Update lookup.js --- packages/blaze/lookup.js | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/packages/blaze/lookup.js b/packages/blaze/lookup.js index 9d5f36c8e..87d427238 100644 --- a/packages/blaze/lookup.js +++ b/packages/blaze/lookup.js @@ -84,6 +84,25 @@ var wrapHelper = function (f, templateFunc) { }; }; +function _lexicalKeepGoing(currentView) { + if (!currentView.parentView) { + return undefined; + } + if (!currentView.__startsNewLexicalScope) { + return currentView.parentView; + } + if (currentView.parentView.__childDoesntStartNewLexicalScope) { + return currentView.parentView; + } + + // in the case of {{> Template.contentBlock data}} the contentBlock loses the lexical scope of it's parent, wheras {{> Template.contentBlock}} it does not + // this is because a #with sits between the include InOuterTemplateScope + if (currentView.parentView.name === "with" && currentView.parentView.parentView && currentView.parentView.parentView.__childDoesntStartNewLexicalScope) { + return currentView.parentView; + } + return undefined; +} + Blaze._lexicalBindingLookup = function (view, name) { var currentView = view; var blockHelpersStack = []; @@ -99,10 +118,7 @@ Blaze._lexicalBindingLookup = function (view, name) { return bindingReactiveVar.get(); }; } - } while (! (currentView.__startsNewLexicalScope && - ! (currentView.parentView && - currentView.parentView.__childDoesntStartNewLexicalScope)) - && (currentView = currentView.parentView)); + } while (currentView = _lexicalKeepGoing(currentView)); return null; }; From 7ec722acc5aea585bf367f058ba013549a1ff842 Mon Sep 17 00:00:00 2001 From: Zack Date: Wed, 29 Dec 2021 10:13:15 -0500 Subject: [PATCH 2/2] Update HISTORY.md --- HISTORY.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/HISTORY.md b/HISTORY.md index 7ae4498cc..1c3025d9e 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,6 @@ +## v2.5.1, 2022-XXX +* [#358](https://github.com/meteor/blaze/pull/358) Make Template.contentBlock consistent with/out data provided + ## v2.5.0, 2021-June-5 * [#331](https://github.com/meteor/blaze/pull/331) Remove underscore and all of its methods in the code