Block.php 971 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. /*
  3. * This file is part of Twig.
  4. *
  5. * (c) 2009 Fabien Potencier
  6. * (c) 2009 Armin Ronacher
  7. *
  8. * For the full copyright and license information, please view the LICENSE
  9. * file that was distributed with this source code.
  10. */
  11. /**
  12. * Represents a block node.
  13. *
  14. * @author Fabien Potencier <fabien@symfony.com>
  15. */
  16. class Twig_Node_Block extends Twig_Node
  17. {
  18. public function __construct($name, Twig_NodeInterface $body, $lineno, $tag = null)
  19. {
  20. parent::__construct(array('body' => $body), array('name' => $name), $lineno, $tag);
  21. }
  22. public function compile(Twig_Compiler $compiler)
  23. {
  24. $compiler
  25. ->addDebugInfo($this)
  26. ->write(sprintf("public function block_%s(\$context, array \$blocks = array())\n", $this->getAttribute('name')), "{\n")
  27. ->indent()
  28. ;
  29. $compiler
  30. ->subcompile($this->getNode('body'))
  31. ->outdent()
  32. ->write("}\n\n")
  33. ;
  34. }
  35. }