Embed.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. * @author Fabien Potencier <fabien@symfony.com>
  14. */
  15. class Twig_Node_Embed extends Twig_Node_Include
  16. {
  17. // we don't inject the module to avoid node visitors to traverse it twice (as it will be already visited in the main module)
  18. public function __construct($filename, $index, Twig_Node_Expression $variables = null, $only = false, $ignoreMissing = false, $lineno, $tag = null)
  19. {
  20. parent::__construct(new Twig_Node_Expression_Constant('not_used', $lineno), $variables, $only, $ignoreMissing, $lineno, $tag);
  21. $this->setAttribute('filename', $filename);
  22. $this->setAttribute('index', $index);
  23. }
  24. protected function addGetTemplate(Twig_Compiler $compiler)
  25. {
  26. $compiler
  27. ->write('$this->loadTemplate(')
  28. ->string($this->getAttribute('filename'))
  29. ->raw(', ')
  30. ->repr($compiler->getFilename())
  31. ->raw(', ')
  32. ->repr($this->getLine())
  33. ->raw(', ')
  34. ->string($this->getAttribute('index'))
  35. ->raw(')')
  36. ;
  37. }
  38. }