4 * This file is part of Twig.
9 * For the full copyright and license information, please view the LICENSE
10 * file that was distributed with this source code.
14 * Extends a template by another one.
17 * {% extends "base.html" %}
22 class Twig_TokenParser_Extends extends Twig_TokenParser
24 public function parse(Twig_Token $token)
26 $stream = $this->parser->getStream();
28 if (!$this->parser->isMainScope()) {
29 throw new Twig_Error_Syntax('Cannot extend from a block.', $token->getLine(), $stream->getSourceContext());
32 if (null !== $this->parser->getParent()) {
33 throw new Twig_Error_Syntax('Multiple extends tags are forbidden.', $token->getLine(), $stream->getSourceContext());
35 $this->parser->setParent($this->parser->getExpressionParser()->parseExpression());
37 $stream->expect(Twig_Token::BLOCK_END_TYPE);
40 public function getTag()
46 class_alias('Twig_TokenParser_Extends', 'Twig\TokenParser\ExtendsTokenParser', false);