StylesheetNode.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. namespace Symfony\Bundle\TwigBundle\Node;
  3. /*
  4. * This file is part of the Symfony package.
  5. *
  6. * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
  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 stylesheet node.
  13. *
  14. * @author Fabien Potencier <fabien.potencier@symfony-project.com>
  15. */
  16. class StylesheetNode extends \Twig_Node
  17. {
  18. public function __construct(\Twig_Node_Expression $expr, \Twig_Node_Expression $attributes, $lineno, $tag = null)
  19. {
  20. parent::__construct(array('expr' => $expr, 'attributes' => $attributes), array(), $lineno, $tag);
  21. }
  22. /**
  23. * Compiles the node to PHP.
  24. *
  25. * @param \Twig_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('templating')->getContainer()->get('templating.helper.stylesheets')->add(")
  32. ->subcompile($this->getNode('expr'))
  33. ->raw(', ')
  34. ->subcompile($this->getNode('attributes'))
  35. ->raw(");\n")
  36. ;
  37. }
  38. }