From 0fe552857468aa12097a74e08f51f5aaa983be07 Mon Sep 17 00:00:00 2001 From: Michael Foster Date: Thu, 1 Aug 2013 15:20:12 -0400 Subject: Upgrade Twig library --- inc/lib/Twig/TokenParser/Include.php | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) (limited to 'inc/lib/Twig/TokenParser/Include.php') diff --git a/inc/lib/Twig/TokenParser/Include.php b/inc/lib/Twig/TokenParser/Include.php index 54154559..4a317868 100644 --- a/inc/lib/Twig/TokenParser/Include.php +++ b/inc/lib/Twig/TokenParser/Include.php @@ -32,37 +32,46 @@ class Twig_TokenParser_Include extends Twig_TokenParser { $expr = $this->parser->getExpressionParser()->parseExpression(); + list($variables, $only, $ignoreMissing) = $this->parseArguments(); + + return new Twig_Node_Include($expr, $variables, $only, $ignoreMissing, $token->getLine(), $this->getTag()); + } + + protected function parseArguments() + { + $stream = $this->parser->getStream(); + $ignoreMissing = false; - if ($this->parser->getStream()->test(Twig_Token::NAME_TYPE, 'ignore')) { - $this->parser->getStream()->next(); - $this->parser->getStream()->expect(Twig_Token::NAME_TYPE, 'missing'); + if ($stream->test(Twig_Token::NAME_TYPE, 'ignore')) { + $stream->next(); + $stream->expect(Twig_Token::NAME_TYPE, 'missing'); $ignoreMissing = true; } $variables = null; - if ($this->parser->getStream()->test(Twig_Token::NAME_TYPE, 'with')) { - $this->parser->getStream()->next(); + if ($stream->test(Twig_Token::NAME_TYPE, 'with')) { + $stream->next(); $variables = $this->parser->getExpressionParser()->parseExpression(); } $only = false; - if ($this->parser->getStream()->test(Twig_Token::NAME_TYPE, 'only')) { - $this->parser->getStream()->next(); + if ($stream->test(Twig_Token::NAME_TYPE, 'only')) { + $stream->next(); $only = true; } - $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE); + $stream->expect(Twig_Token::BLOCK_END_TYPE); - return new Twig_Node_Include($expr, $variables, $only, $ignoreMissing, $token->getLine(), $this->getTag()); + return array($variables, $only, $ignoreMissing); } /** * Gets the tag name associated with this token parser. * - * @param string The tag name + * @return string The tag name */ public function getTag() { -- cgit v1.3