File tree Expand file tree Collapse file tree 1 file changed +17
-1
lines changed
src/TwigComponent/src/Twig Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -68,7 +68,7 @@ public function compile(Compiler $compiler): void
68
68
->raw ('), ' )
69
69
->raw ($ this ->getAttribute ('only ' ) ? '[] ' : '$context ' )
70
70
->raw (', ' )
71
- ->string ($ this ->getAttribute ('name ' ))
71
+ ->string ($ this ->parseTemplateName ( $ this -> getAttribute ('name ' ) ))
72
72
->raw (', ' )
73
73
->raw ($ this ->getAttribute ('index ' ))
74
74
->raw ("); \n" )
@@ -91,4 +91,20 @@ public function compile(Compiler $compiler): void
91
91
->raw ("\n" )
92
92
;
93
93
}
94
+
95
+ /**
96
+ * Copied from Twig\Loader\FilesystemLoader, and adjusted to needs for this class
97
+ */
98
+ private function parseTemplateName (string $ name ): mixed
99
+ {
100
+ if (isset ($ name [0 ]) && '@ ' == $ name [0 ]) {
101
+ if (false === $ pos = strpos ($ name , '/ ' )) {
102
+ throw new \LogicException (sprintf ('Malformed namespaced template name "%s" (expecting "@namespace/template_name"). ' , $ name ));
103
+ }
104
+
105
+ return substr ($ name , $ pos + 1 );
106
+ }
107
+
108
+ return $ name ;
109
+ }
94
110
}
You can’t perform that action at this time.
0 commit comments