vendor/twig/lib/Twig/TokenParser/Extends.php
changeset 0 7f95f8617b0b
equal deleted inserted replaced
-1:000000000000 0:7f95f8617b0b
       
     1 <?php
       
     2 
       
     3 /*
       
     4  * This file is part of Twig.
       
     5  *
       
     6  * (c) 2009 Fabien Potencier
       
     7  * (c) 2009 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 class Twig_TokenParser_Extends extends Twig_TokenParser
       
    21 {
       
    22     /**
       
    23      * Parses a token and returns a node.
       
    24      *
       
    25      * @param Twig_Token $token A Twig_Token instance
       
    26      *
       
    27      * @return Twig_NodeInterface A Twig_NodeInterface instance
       
    28      */
       
    29     public function parse(Twig_Token $token)
       
    30     {
       
    31         if (null !== $this->parser->getParent()) {
       
    32             throw new Twig_Error_Syntax('Multiple extends tags are forbidden', $token->getLine());
       
    33         }
       
    34         $this->parser->setParent($this->parser->getExpressionParser()->parseExpression());
       
    35 
       
    36         $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE);
       
    37 
       
    38         return null;
       
    39     }
       
    40 
       
    41     /**
       
    42      * Gets the tag name associated with this token parser.
       
    43      *
       
    44      * @param string The tag name
       
    45      */
       
    46     public function getTag()
       
    47     {
       
    48         return 'extends';
       
    49     }
       
    50 }