1212/**
1313 * @phpstan-type RegIssue array{
1414 * desc?: string, template: string, data?: mixed, options?: Options,
15- * helpers?: array<string, \Closure>, expected: string,
15+ * helpers?: array<string, \Closure>, runtimePartials?: array<string, string>, expected: string,
1616 * }
1717 */
1818class RegressionTest extends TestCase
@@ -80,6 +80,7 @@ public function testRuntimePartials(): void
8080
8181 /**
8282 * @param array<string, \Closure> $helpers
83+ * @param array<string, string> $runtimePartials
8384 */
8485 #[DataProvider("helperProvider " )]
8586 #[DataProvider("partialProvider " )]
@@ -97,13 +98,14 @@ public function testRuntimePartials(): void
9798 #[DataProvider("missingDataProvider " )]
9899 #[DataProvider("syntaxProvider " )]
99100 #[DataProvider("subexpressionPathProvider " )]
100- public function testIssues (string $ template , string $ expected , string $ desc = '' , mixed $ data = null , ?Options $ options = null , array $ helpers = []): void
101+ public function testIssues (string $ template , string $ expected , string $ desc = '' , mixed $ data = null , ?Options $ options = null , array $ helpers = [], array $ runtimePartials = [] ): void
101102 {
102103 $ templateSpec = Handlebars::precompile ($ template , $ options ?? new Options ());
103104
104105 try {
105106 $ template = Handlebars::template ($ templateSpec );
106- $ result = $ template ($ data , ['helpers ' => $ helpers ]);
107+ $ compiledPartials = array_map (fn ($ p ) => Handlebars::compile ($ p ), $ runtimePartials );
108+ $ result = $ template ($ data , ['helpers ' => $ helpers , 'partials ' => $ compiledPartials ]);
107109 } catch (\Throwable $ e ) {
108110 $ this ->fail ("$ desc \nError: {$ e ->getMessage ()}\nPHP code: \n$ templateSpec " );
109111 }
@@ -1195,6 +1197,17 @@ public static function partialProvider(): array
11951197 ),
11961198 'expected ' => '{ ( [ « < Hello > World! » ] ) } ' ,
11971199 ],
1200+ [
1201+ 'desc ' => 'LNC#292 - nested partials should render correctly (runtime partials) ' ,
1202+ 'template ' => '{ {{#>outer}} {{#>innerBlock}} Hello {{/innerBlock}} {{>simple}} {{/outer}} } ' ,
1203+ 'runtimePartials ' => [
1204+ 'outer ' => '( {{#>nested}} « {{>@partial-block}} » {{/nested}} ) ' ,
1205+ 'nested ' => '[ {{>@partial-block}} ] ' ,
1206+ 'innerBlock ' => '< {{>@partial-block}} > ' ,
1207+ 'simple ' => 'World! ' ,
1208+ ],
1209+ 'expected ' => '{ ( [ « < Hello > World! » ] ) } ' ,
1210+ ],
11981211
11991212 [
12001213 'desc ' => 'LNC#284 - partial strings should be escaped ' ,
0 commit comments