PageRenderTime 40ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/plugins/BTwig/lib/Twig/Node/Expression/Test/Constant.php

http://github.com/unirgy/buckyball
PHP | 35 lines | 14 code | 2 blank | 19 comment | 0 complexity | 8ad30fd85a22b87d91c0af5176b48a72 MD5 | raw file
Possible License(s): LGPL-2.1, BSD-3-Clause
  1. <?php
  2. /*
  3. * This file is part of Twig.
  4. *
  5. * (c) 2011 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. * Checks if a variable is the exact same value as a constant.
  12. *
  13. * <pre>
  14. * {% if post.status is constant('Post::PUBLISHED') %}
  15. * the status attribute is exactly the same as Post::PUBLISHED
  16. * {% endif %}
  17. * </pre>
  18. *
  19. * @author Fabien Potencier <fabien@symfony.com>
  20. */
  21. class Twig_Node_Expression_Test_Constant extends Twig_Node_Expression_Test
  22. {
  23. public function compile(Twig_Compiler $compiler)
  24. {
  25. $compiler
  26. ->raw('(')
  27. ->subcompile($this->getNode('node'))
  28. ->raw(' === constant(')
  29. ->subcompile($this->getNode('arguments')->getNode(0))
  30. ->raw('))')
  31. ;
  32. }
  33. }