mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-13 10:56:38 +00:00
added support for macro name in the endmacro tag
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
Changes:
|
||||
|
||||
* added support for macro name in the endmacro tag
|
||||
* fixed the "length" filter for numbers
|
||||
* removed coupling between Twig_Node and Twig_Template
|
||||
* fixed the ternary operator precedence rule
|
||||
|
||||
@@ -27,6 +27,13 @@ class Twig_TokenParser_Macro extends Twig_TokenParser
|
||||
$this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE);
|
||||
$this->parser->pushLocalScope();
|
||||
$body = $this->parser->subparse(array($this, 'decideBlockEnd'), true);
|
||||
if ($this->parser->getStream()->test(Twig_Token::NAME_TYPE)) {
|
||||
$value = $this->parser->getStream()->next()->getValue();
|
||||
|
||||
if ($value != $name) {
|
||||
throw new Twig_Error_Syntax(sprintf("Expected endmacro for macro '$name' (but %s given)", $value), $lineno);
|
||||
}
|
||||
}
|
||||
$this->parser->popLocalScope();
|
||||
$this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE);
|
||||
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
--TEST--
|
||||
"macro" tag supports name for endmacro
|
||||
--TEMPLATE--
|
||||
{{ _self.foo() }}
|
||||
{{ _self.bar() }}
|
||||
|
||||
{% macro foo() %}foo{% endmacro %}
|
||||
{% macro bar() %}bar{% endmacro bar %}
|
||||
--DATA--
|
||||
return array()
|
||||
--EXPECT--
|
||||
foo
|
||||
bar
|
||||
|
||||
Reference in New Issue
Block a user