[ Index ]

PHP Cross Reference of phpBB-3.2.11-deutsch

title

Body

[close]

/vendor/twig/twig/src/TokenParser/ -> SpacelessTokenParser.php (source)

   1  <?php
   2  
   3  /*
   4   * This file is part of Twig.
   5   *
   6   * (c) Fabien Potencier
   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  namespace Twig\TokenParser;
  13  
  14  use Twig\Node\SpacelessNode;
  15  use Twig\Token;
  16  
  17  /**
  18   * Remove whitespaces between HTML tags.
  19   *
  20   *   {% spaceless %}
  21   *      <div>
  22   *          <strong>foo</strong>
  23   *      </div>
  24   *   {% endspaceless %}
  25   *   {# output will be <div><strong>foo</strong></div> #}
  26   *
  27   * @final
  28   */
  29  class SpacelessTokenParser extends AbstractTokenParser
  30  {
  31      public function parse(Token $token)
  32      {
  33          $lineno = $token->getLine();
  34  
  35          $this->parser->getStream()->expect(Token::BLOCK_END_TYPE);
  36          $body = $this->parser->subparse([$this, 'decideSpacelessEnd'], true);
  37          $this->parser->getStream()->expect(Token::BLOCK_END_TYPE);
  38  
  39          return new SpacelessNode($body, $lineno, $this->getTag());
  40      }
  41  
  42      public function decideSpacelessEnd(Token $token)
  43      {
  44          return $token->test('endspaceless');
  45      }
  46  
  47      public function getTag()
  48      {
  49          return 'spaceless';
  50      }
  51  }
  52  
  53  class_alias('Twig\TokenParser\SpacelessTokenParser', 'Twig_TokenParser_Spaceless');


Generated: Wed Nov 11 20:33:01 2020 Cross-referenced by PHPXref 0.7.1