Skip to content

Commit

Permalink
TexyNode: fixed compatibility with Latte 3.0.14
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Mar 19, 2024
1 parent bb922d4 commit 21f9138
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
5 changes: 4 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,12 @@
"require-dev": {
"nette/tester": "^2.0",
"tracy/tracy": "^2.4",
"latte/latte": "^2.6 || ^3.0.2",
"latte/latte": "^2.6 || ^3.0.14",
"phpstan/phpstan": "^0.12"
},
"conflict": {
"latte/latte": ">=3.0.0 <3.0.14"
},
"replace": {
"dg/texy": "*"
},
Expand Down
7 changes: 5 additions & 2 deletions src/Bridges/Latte/TexyNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public static function create(Tag $tag, TemplateParser $parser, callable $proces

$lexer = $parser->getLexer();
$savedC = $parser->getContentType();
$savedD = [$lexer->openDelimiter, $lexer->closeDelimiter];
$syntax = false;

$node = new static;
$node->args = $tag->parser->parseArguments();
Expand All @@ -47,6 +47,7 @@ public static function create(Tag $tag, TemplateParser $parser, callable $proces
if ($arg->key instanceof IdentifierNode && $arg->key->name === 'syntax') {
array_splice($node->args->items, $i, 1);
$lexer->setSyntax(NodeHelpers::toValue($arg->value), $tag->name);
$syntax = true;
break;
}
}
Expand All @@ -56,7 +57,9 @@ public static function create(Tag $tag, TemplateParser $parser, callable $proces
[$node->content] = yield;

$parser->setContentType($savedC);
[$lexer->openDelimiter, $lexer->closeDelimiter] = $savedD;
if ($syntax) {
$lexer->popSyntax();
}

$text = NodeHelpers::toText($node->content);
if ($text !== null) {
Expand Down

0 comments on commit 21f9138

Please sign in to comment.