@@ -119,7 +119,7 @@ public function stream(RenderContext $context): \Generator
119119 $ forLoop = new ForLoopDrop ($ templateName , count ($ variable ));
120120
121121 foreach ($ variable as $ value ) {
122- $ partialContext = $ this ->setInnerContextVariables ($ context-> newIsolatedSubContext ( $ templateName) , [
122+ $ partialContext = $ this ->buildPartialContext ($ context, $ templateName , [
123123 'forloop ' => $ forLoop ,
124124 $ contextVariableName => $ value ,
125125 ]);
@@ -132,7 +132,7 @@ public function stream(RenderContext $context): \Generator
132132 return ;
133133 }
134134
135- $ partialContext = $ this ->setInnerContextVariables ($ context-> newIsolatedSubContext ( $ templateName) , [
135+ $ partialContext = $ this ->buildPartialContext ($ context, $ templateName , [
136136 $ contextVariableName => $ variable ,
137137 ]);
138138
@@ -162,17 +162,19 @@ protected function loadPartial(RenderContext $context): Template
162162 return $ context ->loadPartial ($ templateName , parseIfMissing: $ this ->allowDynamicPartials ());
163163 }
164164
165- protected function setInnerContextVariables (RenderContext $ context , array $ variables = []): RenderContext
165+ protected function buildPartialContext (RenderContext $ rootContext , string $ templateName , array $ variables = []): RenderContext
166166 {
167+ $ partialContext = $ rootContext ->newIsolatedSubContext ($ templateName );
168+
167169 foreach ($ variables as $ key => $ value ) {
168- $ context ->set ($ key , $ value );
170+ $ partialContext ->set ($ key , $ value );
169171 }
170172
171173 foreach ($ this ->attributes as $ key => $ value ) {
172- $ context ->set ($ key , $ context ->evaluate ($ value ));
174+ $ partialContext ->set ($ key , $ rootContext ->evaluate ($ value ));
173175 }
174176
175- return $ context ;
177+ return $ partialContext ;
176178 }
177179
178180 protected function allowDynamicPartials (): bool
0 commit comments