Skip to content

Commit

Permalink
TemplateParserHtml: HTML attribute name can be PrintNode or string
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Aug 12, 2023
1 parent c5e55fa commit 7a2da3d
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions src/Latte/Compiler/TemplateParserHtml.php
Original file line number Diff line number Diff line change
Expand Up @@ -259,19 +259,16 @@ private function parseAttributeWhitespace(): Node
private function parseAttribute(): ?Node
{
$stream = $this->parser->getStream();
$followsLatte = $stream->is(Token::Latte_TagOpen);
$save = $stream->getIndex();
try {
if ($stream->is(Token::Latte_TagOpen)) {
$name = $this->parser->parseLatteStatement();
if (!$name instanceof Latte\Essential\Nodes\PrintNode) {
return $name; // value like '<span {if true}attr1=val{/if}>'
}
} else {
$name = $this->parseAttributeName();
if (!$name) {
return null;
}
} catch (CompileException $e) {
if ($followsLatte && $stream->peek()) { // it is not lexer exception
$stream->seek($save);
return $this->parser->parseLatteStatement(); // attribute name with the value like '<span {if true}attr1=val{/if}>'
}
throw $e;
}

[$value, $quote] = $this->parseAttributeValue();
Expand Down

0 comments on commit 7a2da3d

Please sign in to comment.