Skip to content

Commit

Permalink
BlockMacros: <tag> in {snippet} is deprecated
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Jun 19, 2016
1 parent f5f5c04 commit c9ec81d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/Latte/Macros/BlockMacros.php
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,9 @@ public function macroBlock(MacroNode $node, PhpWriter $writer)
return $writer->write($enterCode);
}
$tag = trim($node->tokenizer->fetchWord(), '<>');
if ($tag) {
trigger_error('HTML tag specified in {snippet} is deprecated, use n:snippet.', E_USER_DEPRECATED);
}
$tag = $tag ? $tag : 'div';
$node->closingCode .= "\n</$tag>";
$this->checkExtraArgs($node);
Expand Down Expand Up @@ -286,6 +289,9 @@ public function macroBlock(MacroNode $node, PhpWriter $writer)
return $writer->write($include, $name);
}
$tag = trim($node->tokenizer->fetchWord(), '<>');
if ($tag) {
trigger_error('HTML tag specified in {snippet} is deprecated, use n:snippet.', E_USER_DEPRECATED);
}
$tag = $tag ? $tag : 'div';
$this->checkExtraArgs($node);
return $writer->write("?>\n<$tag id=\"<?php echo htmlSpecialChars(\$this->global->snippetDriver->getHtmlId(%var)) ?>\"><?php $include ?>\n</$tag><?php ",
Expand Down
2 changes: 1 addition & 1 deletion tests/Latte/BlockMacros.snippet.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,5 @@ EOD;

Assert::matchFile(
__DIR__ . '/expected/BlockMacros.snippet.phtml',
$latte->compile($template)
@$latte->compile($template) // @ tag in {snippet} is deprecated
);

0 comments on commit c9ec81d

Please sign in to comment.