Body.php 938 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. /*
  3. * This file is part of Twig.
  4. *
  5. * (c) 2010 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. * @deprecated since version 1.5
  12. */
  13. class Twig_Extensions_Grammar_Body extends Twig_Extensions_Grammar
  14. {
  15. protected $end;
  16. public function __construct($name, $end = null)
  17. {
  18. parent::__construct($name);
  19. $this->end = null === $end ? 'end'.$name : $end;
  20. }
  21. public function __toString()
  22. {
  23. return sprintf('<%s:body>', $this->name);
  24. }
  25. public function parse(Twig_Token $token)
  26. {
  27. $stream = $this->parser->getStream();
  28. $stream->expect(Twig_Token::BLOCK_END_TYPE);
  29. return $this->parser->subparse(array($this, 'decideBlockEnd'), true);
  30. }
  31. public function decideBlockEnd(Twig_Token $token)
  32. {
  33. return $token->test($this->end);
  34. }
  35. }