diff --git a/latte/src/Latte/Macros/BlockMacros.php b/latte/src/Latte/Macros/BlockMacros.php index c7e7ef7398f..abb72965366 100644 --- a/latte/src/Latte/Macros/BlockMacros.php +++ b/latte/src/Latte/Macros/BlockMacros.php @@ -22,6 +22,9 @@ */ class BlockMacros extends MacroSet { + /** @var string */ + public $snippetAttribute = 'id'; + /** @var array */ private $namedBlocks = []; @@ -240,12 +243,12 @@ public function macroBlock(MacroNode $node, PhpWriter $writer) $enterCode = '$this->global->snippetDriver->enter(' . $writer->formatWord($name) . ', "' . SnippetDriver::TYPE_DYNAMIC . '");'; if ($node->prefix) { - $node->attrCode = $writer->write("global->snippetDriver->getHtmlId({$writer->formatWord($name)})) . '\"' ?>"); + $node->attrCode = $writer->write("snippetAttribute=\"' . htmlSpecialChars(\$this->global->snippetDriver->getHtmlId({$writer->formatWord($name)})) . '\"' ?>"); return $writer->write($enterCode); } $node->closingCode .= "\n"; $this->checkExtraArgs($node); - return $writer->write("?>\n