Print.php 958B

1234567891011121314151617181920212223242526272829303132333435363738394041
  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 node that outputs an expression.
  13. *
  14. * @package twig
  15. * @author Fabien Potencier <fabien@symfony.com>
  16. */
  17. class Twig_Node_Print extends Twig_Node implements Twig_NodeOutputInterface
  18. {
  19. public function __construct(Twig_Node_Expression $expr, $lineno, $tag = null)
  20. {
  21. parent::__construct(array('expr' => $expr), array(), $lineno, $tag);
  22. }
  23. /**
  24. * Compiles the node to PHP.
  25. *
  26. * @param Twig_Compiler A Twig_Compiler instance
  27. */
  28. public function compile(Twig_Compiler $compiler)
  29. {
  30. $compiler
  31. ->addDebugInfo($this)
  32. ->write('echo ')
  33. ->subcompile($this->getNode('expr'))
  34. ->raw(";\n")
  35. ;
  36. }
  37. }