Yaffs site version 1.1
[yaffs-website] / vendor / twig / twig / lib / Twig / TokenParser / Extends.php
1 <?php
2
3 /*
4  * This file is part of Twig.
5  *
6  * (c) Fabien Potencier
7  * (c) Armin Ronacher
8  *
9  * For the full copyright and license information, please view the LICENSE
10  * file that was distributed with this source code.
11  */
12
13 /**
14  * Extends a template by another one.
15  *
16  * <pre>
17  *  {% extends "base.html" %}
18  * </pre>
19  *
20  * @final
21  */
22 class Twig_TokenParser_Extends extends Twig_TokenParser
23 {
24     public function parse(Twig_Token $token)
25     {
26         $stream = $this->parser->getStream();
27
28         if (!$this->parser->isMainScope()) {
29             throw new Twig_Error_Syntax('Cannot extend from a block.', $token->getLine(), $stream->getSourceContext());
30         }
31
32         if (null !== $this->parser->getParent()) {
33             throw new Twig_Error_Syntax('Multiple extends tags are forbidden.', $token->getLine(), $stream->getSourceContext());
34         }
35         $this->parser->setParent($this->parser->getExpressionParser()->parseExpression());
36
37         $stream->expect(Twig_Token::BLOCK_END_TYPE);
38     }
39
40     public function getTag()
41     {
42         return 'extends';
43     }
44 }
45
46 class_alias('Twig_TokenParser_Extends', 'Twig\TokenParser\ExtendsTokenParser', false);