getLine(); $stream = $this->parser->getStream(); $name = $this->parser->getExpressionParser()->parseExpression(); $paramNames = []; $nodes = [$name]; $end = false; while (!$end) { $current = $stream->next(); switch ($current->getType()) { case Twig_Token::NAME_TYPE: $paramNames[] = $current->getValue(); $stream->expect(Twig_Token::OPERATOR_TYPE, '='); $nodes[] = $this->parser->getExpressionParser()->parseExpression(); break; case Twig_Token::BLOCK_END_TYPE: $end = true; break; default: throw new Twig_Error_Syntax( sprintf('Invalid syntax in the partial tag. Line %s', $lineno), $stream->getCurrent()->getLine(), $stream->getFilename() ); break; } } $body = $this->parser->subparse([$this, 'decideComponentEnd'], true); $stream->expect(Twig_Token::BLOCK_END_TYPE); return new MailComponentNode(new Twig_Node($nodes), $paramNames, $body, $token->getLine(), $this->getTag()); } public function decideComponentEnd(Twig_Token $token) { return $token->test('endcomponent'); } /** * Gets the tag name associated with this token parser. * * @return string The tag name */ public function getTag() { return 'component'; } }