@@ -71,14 +71,7 @@ public function fn(mixed $context = Scope::Use, mixed $data = null): string
7171 }
7272 return '' ;
7373 }
74- $ cx = $ this ->cx ;
75- // Save inlinePartials so that any {{#* inline}} partials registered inside the block body
76- // don't leak out after fn() returns. The spec requires inline partials to be
77- // block-scoped. PHP copy-on-write makes this assignment cheap when no inline partials are registered.
78- $ savedInlinePartials = $ cx ->inlinePartials ;
79- $ ret = $ this ->invokeBlock ($ this ->cb , $ context , $ data );
80- $ cx ->inlinePartials = $ savedInlinePartials ;
81- return $ ret ;
74+ return $ this ->invokeBlock ($ this ->cb , $ context , $ data );
8275 }
8376
8477 public function inverse (mixed $ context = Scope::Use, mixed $ data = null ): string
@@ -95,6 +88,10 @@ public function inverse(mixed $context = Scope::Use, mixed $data = null): string
9588 private function invokeBlock (\Closure $ closure , mixed $ context , mixed $ data ): string
9689 {
9790 $ cx = $ this ->cx ;
91+ // Save inlinePartials so that any {{#* inline}} partials registered inside the block body
92+ // don't leak out after it returns. The spec requires inline partials to be
93+ // block-scoped. PHP copy-on-write makes this assignment cheap when no inline partials are registered.
94+ $ savedInlinePartials = $ cx ->inlinePartials ;
9895 $ scope = $ this ->scope ;
9996 // Skip depths push when the caller explicitly passes the current scope (equivalent to
10097 // HBS.js options.fn(this) / options.inverse(this)), since the scope level isn't changing.
@@ -129,6 +126,7 @@ private function invokeBlock(\Closure $closure, mixed $context, mixed $data): st
129126 if ($ savedFrame !== null ) {
130127 $ cx ->frame = $ savedFrame ;
131128 }
129+ $ cx ->inlinePartials = $ savedInlinePartials ;
132130 return $ ret ;
133131 }
134132
0 commit comments