您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

Body.php 896B

123456789101112131415161718192021222324252627282930313233343536373839
  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. class Twig_Extensions_Grammar_Body extends Twig_Extensions_Grammar
  11. {
  12. protected $end;
  13. public function __construct($name, $end = null)
  14. {
  15. parent::__construct($name);
  16. $this->end = null === $end ? 'end'.$name : $end;
  17. }
  18. public function __toString()
  19. {
  20. return sprintf('<%s:body>', $this->name);
  21. }
  22. public function parse(Twig_Token $token)
  23. {
  24. $stream = $this->parser->getStream();
  25. $stream->expect(Twig_Token::BLOCK_END_TYPE);
  26. return $this->parser->subparse(array($this, 'decideBlockEnd'), true);
  27. }
  28. public function decideBlockEnd(Twig_Token $token)
  29. {
  30. return $token->test($this->end);
  31. }
  32. }