summaryrefslogtreecommitdiff
path: root/inc/lib/Twig/TokenParser/Macro.php
diff options
context:
space:
mode:
authorMichael Foster <savetheinternet@tinyboard.org>2013-08-01 15:20:12 -0400
committerMichael Foster <savetheinternet@tinyboard.org>2013-08-01 15:20:12 -0400
commit0fe552857468aa12097a74e08f51f5aaa983be07 (patch)
tree22dbca1be90d7086b20a077752552296abf23325 /inc/lib/Twig/TokenParser/Macro.php
parent22f3a95e0e421de05a11633eac846df96a2a4768 (diff)
Upgrade Twig library
Diffstat (limited to 'inc/lib/Twig/TokenParser/Macro.php')
-rw-r--r--inc/lib/Twig/TokenParser/Macro.php21
1 files changed, 10 insertions, 11 deletions
diff --git a/inc/lib/Twig/TokenParser/Macro.php b/inc/lib/Twig/TokenParser/Macro.php
index da1ac55c..82b4fa6d 100644
--- a/inc/lib/Twig/TokenParser/Macro.php
+++ b/inc/lib/Twig/TokenParser/Macro.php
@@ -30,26 +30,25 @@ class Twig_TokenParser_Macro extends Twig_TokenParser
public function parse(Twig_Token $token)
{
$lineno = $token->getLine();
- $name = $this->parser->getStream()->expect(Twig_Token::NAME_TYPE)->getValue();
+ $stream = $this->parser->getStream();
+ $name = $stream->expect(Twig_Token::NAME_TYPE)->getValue();
- $arguments = $this->parser->getExpressionParser()->parseArguments();
+ $arguments = $this->parser->getExpressionParser()->parseArguments(true, true);
- $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE);
+ $stream->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 ($stream->test(Twig_Token::NAME_TYPE)) {
+ $value = $stream->next()->getValue();
if ($value != $name) {
- throw new Twig_Error_Syntax(sprintf("Expected endmacro for macro '$name' (but %s given)", $value), $lineno);
+ throw new Twig_Error_Syntax(sprintf("Expected endmacro for macro '$name' (but %s given)", $value), $stream->getCurrent()->getLine(), $stream->getFilename());
}
}
$this->parser->popLocalScope();
- $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE);
+ $stream->expect(Twig_Token::BLOCK_END_TYPE);
- $this->parser->setMacro($name, new Twig_Node_Macro($name, $body, $arguments, $lineno, $this->getTag()));
-
- return null;
+ $this->parser->setMacro($name, new Twig_Node_Macro($name, new Twig_Node_Body(array($body)), $arguments, $lineno, $this->getTag()));
}
public function decideBlockEnd(Twig_Token $token)
@@ -60,7 +59,7 @@ class Twig_TokenParser_Macro extends Twig_TokenParser
/**
* Gets the tag name associated with this token parser.
*
- * @param string The tag name
+ * @return string The tag name
*/
public function getTag()
{