Project

General

Profile

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
 * Represents a block node.
15
 *
16
 * @package    twig
17
 * @author     Fabien Potencier <fabien@symfony.com>
18
 */
19
class Twig_Node_Block extends Twig_Node
20
{
21
    public function __construct($name, Twig_NodeInterface $body, $lineno, $tag = null)
22
    {
23
        parent::__construct(array('body' => $body), array('name' => $name), $lineno, $tag);
24
    }
25

    
26
    /**
27
     * Compiles the node to PHP.
28
     *
29
     * @param Twig_Compiler A Twig_Compiler instance
30
     */
31
    public function compile(Twig_Compiler $compiler)
32
    {
33
        $compiler
34
            ->addDebugInfo($this)
35
            ->write(sprintf("public function block_%s(\$context, array \$blocks = array())\n", $this->getAttribute('name')), "{\n")
36
            ->indent()
37
        ;
38

    
39
        $compiler
40
            ->subcompile($this->getNode('body'))
41
            ->outdent()
42
            ->write("}\n\n")
43
        ;
44
    }
45
}
(2-2/22)