Parent.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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 parent node.
  13. *
  14. * @author Fabien Potencier <fabien@symfony.com>
  15. */
  16. class Twig_Node_Expression_Parent extends Twig_Node_Expression
  17. {
  18. public function __construct($name, $lineno, $tag = null)
  19. {
  20. parent::__construct(array(), array('output' => false, 'name' => $name), $lineno, $tag);
  21. }
  22. public function compile(Twig_Compiler $compiler)
  23. {
  24. if ($this->getAttribute('output')) {
  25. $compiler
  26. ->addDebugInfo($this)
  27. ->write('$this->displayParentBlock(')
  28. ->string($this->getAttribute('name'))
  29. ->raw(", \$context, \$blocks);\n")
  30. ;
  31. } else {
  32. $compiler
  33. ->raw('$this->renderParentBlock(')
  34. ->string($this->getAttribute('name'))
  35. ->raw(', $context, $blocks)')
  36. ;
  37. }
  38. }
  39. }