Embed.php 1.2KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. /*
  3. * This file is part of Twig.
  4. *
  5. * (c) 2012 Fabien Potencier
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. /**
  11. * Represents an embed node.
  12. *
  13. * @package twig
  14. * @author Fabien Potencier <fabien@symfony.com>
  15. */
  16. class Twig_Node_Embed extends Twig_Node_Include
  17. {
  18. // we don't inject the module to avoid node visitors to traverse it twice (as it will be already visited in the main module)
  19. public function __construct($filename, $index, Twig_Node_Expression $variables = null, $only = false, $ignoreMissing = false, $lineno, $tag = null)
  20. {
  21. parent::__construct(new Twig_Node_Expression_Constant('not_used', $lineno), $variables, $only, $ignoreMissing, $lineno, $tag);
  22. $this->setAttribute('filename', $filename);
  23. $this->setAttribute('index', $index);
  24. }
  25. protected function addGetTemplate(Twig_Compiler $compiler)
  26. {
  27. $compiler
  28. ->write("\$this->env->loadTemplate(")
  29. ->string($this->getAttribute('filename'))
  30. ->raw(', ')
  31. ->string($this->getAttribute('index'))
  32. ->raw(")")
  33. ;
  34. }
  35. }