RenderNode.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Bundle\TwigBundle\Node;
  11. /**
  12. * Represents a render node.
  13. *
  14. * @author Fabien Potencier <fabien@symfony.com>
  15. */
  16. class RenderNode extends \Twig_Node
  17. {
  18. public function __construct(\Twig_Node_Expression $expr, \Twig_Node_Expression $attributes, \Twig_Node_Expression $options, $lineno, $tag = null)
  19. {
  20. parent::__construct(array('expr' => $expr, 'attributes' => $attributes, 'options' => $options), array(), $lineno, $tag);
  21. }
  22. /**
  23. * Compiles the node to PHP.
  24. *
  25. * @param \Twig_Compiler $compiler A Twig_Compiler instance
  26. */
  27. public function compile(\Twig_Compiler $compiler)
  28. {
  29. $compiler
  30. ->addDebugInfo($this)
  31. ->write("echo \$this->env->getExtension('actions')->renderAction(")
  32. ->subcompile($this->getNode('expr'))
  33. ->raw(', ')
  34. ->subcompile($this->getNode('attributes'))
  35. ->raw(', ')
  36. ->subcompile($this->getNode('options'))
  37. ->raw(");\n")
  38. ;
  39. }
  40. }