[ Index ]

PHP Cross Reference of phpBB-3.3.5-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   * @deprecated since Twig 2.7, to be removed in 3.0 (use the "spaceless" filter with the "apply" tag instead)
  28   */
  29  final class SpacelessTokenParser extends AbstractTokenParser
  30  {
  31      public function parse(Token $token)
  32      {
  33          $stream = $this->parser->getStream();
  34          $lineno = $token->getLine();
  35  
  36          @trigger_error(sprintf('The spaceless tag in "%s" at line %d is deprecated since Twig 2.7, use the "spaceless" filter with the "apply" tag instead.', $stream->getSourceContext()->getName(), $lineno), E_USER_DEPRECATED);
  37  
  38          $stream->expect(/* Token::BLOCK_END_TYPE */ 3);
  39          $body = $this->parser->subparse([$this, 'decideSpacelessEnd'], true);
  40          $stream->expect(/* Token::BLOCK_END_TYPE */ 3);
  41  
  42          return new SpacelessNode($body, $lineno, $this->getTag());
  43      }
  44  
  45      public function decideSpacelessEnd(Token $token)
  46      {
  47          return $token->test('endspaceless');
  48      }
  49  
  50      public function getTag()
  51      {
  52          return 'spaceless';
  53      }
  54  }
  55  
  56  class_alias('Twig\TokenParser\SpacelessTokenParser', 'Twig_TokenParser_Spaceless');


Generated: Mon Oct 4 17:42:11 2021 Cross-referenced by PHPXref 0.7.1