@@ -36,9 +36,8 @@ final class TemplateLexer
3636 'double ' => ['\{\{(?![\s \'"{}]) ' , '\}\} ' ], // {{...}}
3737 'off ' => ['\{(?=/syntax\}) ' , '\} ' ], // {/syntax}
3838 ];
39-
40- /** @var string[] */
41- private array $ delimiters ;
39+ public string $ openDelimiter ;
40+ public string $ closeDelimiter ;
4241 private TagLexer $ tagLexer ;
4342
4443 /** @var array<array{name: string, args: mixed[]}> */
@@ -77,8 +76,8 @@ private function statePlain(): \Generator
7776 (?<Text>.+?)??
7877 (?<Indentation>(?<=\n|^)[ \t]+)?
7978 (
80- (?<Latte_TagOpen> ' . $ this ->delimiters [ 0 ] . '(?!\*))| # {tag
81- (?<Latte_CommentOpen> ' . $ this ->delimiters [ 0 ] . '\*)| # {* comment
79+ (?<Latte_TagOpen> ' . $ this ->openDelimiter . '(?!\*))| # {tag
80+ (?<Latte_CommentOpen> ' . $ this ->openDelimiter . '\*)| # {* comment
8281 $
8382 )
8483 ~xsiAuD ' );
@@ -105,7 +104,7 @@ private function stateLatteTag(): \Generator
105104
106105 yield from $ this ->match ('~
107106 (?<Slash>/)?
108- (?<Latte_TagClose> ' . $ this ->delimiters [ 1 ] . ')
107+ (?<Latte_TagClose> ' . $ this ->closeDelimiter . ')
109108 (?<Newline>[ \t]*\R)?
110109 ~xsiAu ' );
111110 }
@@ -116,7 +115,7 @@ private function stateLatteComment(): \Generator
116115 $ this ->popState ();
117116 yield from $ this ->match ('~
118117 (?<Text>.+?)??
119- (?<Latte_CommentClose>\* ' . $ this ->delimiters [ 1 ] . ')
118+ (?<Latte_CommentClose>\* ' . $ this ->closeDelimiter . ')
120119 (?<Newline>[ \t]*\R{1,2})?
121120 ~xsiAu ' );
122121 }
@@ -130,8 +129,8 @@ private function stateHtmlText(): \Generator
130129 (?<Indentation>(?<=\n|^)[ \t]+)?(?<Html_TagOpen><)(?<Slash>/)?(?<Html_Name> ' . self ::ReTagName . ')| # <tag </tag
131130 (?<Html_CommentOpen><!--(?!>|->))| # <!-- comment
132131 (?<Html_BogusOpen><[/?!])| # <!doctype <?xml or error
133- (?<Indentation>(?<=\n|^)[ \t]+)?(?<Latte_TagOpen> ' . $ this ->delimiters [ 0 ] . '(?!\*))| # {tag
134- (?<Indentation>(?<=\n|^)[ \t]+)?(?<Latte_CommentOpen> ' . $ this ->delimiters [ 0 ] . '\*)| # {* comment
132+ (?<Indentation>(?<=\n|^)[ \t]+)?(?<Latte_TagOpen> ' . $ this ->openDelimiter . '(?!\*))| # {tag
133+ (?<Indentation>(?<=\n|^)[ \t]+)?(?<Latte_CommentOpen> ' . $ this ->openDelimiter . '\*)| # {* comment
135134 $
136135 )
137136 ~xsiAuD ' );
@@ -161,8 +160,8 @@ private function stateHtmlTag(?string $tagName = null, ?string $attrName = null)
161160 (?<Quote>[" \'])|
162161 (?<Slash>/)?(?<Html_TagClose>>)(?<Newline>[ \t]*\R)?| # > />
163162 (?<Html_Name> ' . self ::ReHtmlName . ')| # HTML attribute name/value
164- (?<Latte_TagOpen> ' . $ this ->delimiters [ 0 ] . '(?!\*))| # {tag
165- (?<Latte_CommentOpen> ' . $ this ->delimiters [ 0 ] . '\*) # {* comment
163+ (?<Latte_TagOpen> ' . $ this ->openDelimiter . '(?!\*))| # {tag
164+ (?<Latte_CommentOpen> ' . $ this ->openDelimiter . '\*) # {* comment
166165 ~xsiAu ' );
167166
168167 if (isset ($ m ['Html_Name ' ])) {
@@ -201,8 +200,8 @@ private function stateHtmlQuotedValue(string $quote): \Generator
201200 $ m = yield from $ this ->match ('~
202201 (?<Text>.+?)??(
203202 (?<Quote> ' . $ quote . ')|
204- (?<Latte_TagOpen> ' . $ this ->delimiters [ 0 ] . '(?!\*))| # {tag
205- (?<Latte_CommentOpen> ' . $ this ->delimiters [ 0 ] . '\*) # {* comment
203+ (?<Latte_TagOpen> ' . $ this ->openDelimiter . '(?!\*))| # {tag
204+ (?<Latte_CommentOpen> ' . $ this ->openDelimiter . '\*) # {* comment
206205 )
207206 ~xsiAu ' );
208207
@@ -239,8 +238,8 @@ private function stateHtmlRCData(string $tagName): \Generator
239238 (?<Indentation>(?<=\n|^)[ \t]+)?
240239 (
241240 (?<Html_TagOpen><)(?<Slash>/)(?<Html_Name> ' . preg_quote ($ tagName , '~ ' ) . ')| # </tag
242- (?<Latte_TagOpen> ' . $ this ->delimiters [ 0 ] . '(?!\*))| # {tag
243- (?<Latte_CommentOpen> ' . $ this ->delimiters [ 0 ] . '\*)| # {* comment
241+ (?<Latte_TagOpen> ' . $ this ->openDelimiter . '(?!\*))| # {tag
242+ (?<Latte_CommentOpen> ' . $ this ->openDelimiter . '\*)| # {* comment
244243 $
245244 )
246245 ~xsiAu ' );
@@ -263,8 +262,8 @@ private function stateHtmlComment(): \Generator
263262 (?<Text>.+?)??
264263 (
265264 (?<Html_CommentClose>-->)| # -->
266- (?<Indentation>(?<=\n|^)[ \t]+)?(?<Latte_TagOpen> ' . $ this ->delimiters [ 0 ] . '(?!\*))| # {tag
267- (?<Indentation>(?<=\n|^)[ \t]+)?(?<Latte_CommentOpen> ' . $ this ->delimiters [ 0 ] . '\*) # {* comment
265+ (?<Indentation>(?<=\n|^)[ \t]+)?(?<Latte_TagOpen> ' . $ this ->openDelimiter . '(?!\*))| # {tag
266+ (?<Indentation>(?<=\n|^)[ \t]+)?(?<Latte_CommentOpen> ' . $ this ->openDelimiter . '\*) # {* comment
268267 )
269268 ~xsiAu ' );
270269
@@ -285,8 +284,8 @@ private function stateHtmlBogus(): \Generator
285284 $ m = yield from $ this ->match ('~
286285 (?<Text>.+?)??(
287286 (?<Html_TagClose>>)| # >
288- (?<Latte_TagOpen> ' . $ this ->delimiters [ 0 ] . '(?!\*))| # {tag
289- (?<Latte_CommentOpen> ' . $ this ->delimiters [ 0 ] . '\*) # {* comment
287+ (?<Latte_TagOpen> ' . $ this ->openDelimiter . '(?!\*))| # {tag
288+ (?<Latte_CommentOpen> ' . $ this ->openDelimiter . '\*) # {* comment
290289 )
291290 ~xsiAu ' );
292291
@@ -359,7 +358,7 @@ private function popState(): void
359358
360359
361360 /**
362- * Changes macro tag delimiters.
361+ * Changes tag delimiters.
363362 */
364363 public function setSyntax (?string $ type ): static
365364 {
@@ -368,17 +367,7 @@ public function setSyntax(?string $type): static
368367 throw new \InvalidArgumentException ("Unknown syntax ' $ type' " );
369368 }
370369
371- $ this ->setDelimiters ($ this ->syntaxes [$ type ][0 ], $ this ->syntaxes [$ type ][1 ]);
372- return $ this ;
373- }
374-
375-
376- /**
377- * Changes macro tag delimiters (as regular expression).
378- */
379- public function setDelimiters (string $ left , string $ right ): static
380- {
381- $ this ->delimiters = [$ left , $ right ];
370+ [$ this ->openDelimiter , $ this ->closeDelimiter ] = $ this ->syntaxes [$ type ];
382371 return $ this ;
383372 }
384373
0 commit comments