vendor/twig/twig/src/TokenParser/SpacelessTokenParser.php line 33

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of Twig.
  4.  *
  5.  * (c) 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. namespace Twig\TokenParser;
  11. use Twig\Node\SpacelessNode;
  12. use Twig\Token;
  13. /**
  14.  * Remove whitespaces between HTML tags.
  15.  *
  16.  *   {% spaceless %}
  17.  *      <div>
  18.  *          <strong>foo</strong>
  19.  *      </div>
  20.  *   {% endspaceless %}
  21.  *   {# output will be <div><strong>foo</strong></div> #}
  22.  *
  23.  * @deprecated since Twig 2.7, to be removed in 3.0 (use the spaceless filter instead)
  24.  */
  25. final class SpacelessTokenParser extends AbstractTokenParser
  26. {
  27.     public function parse(Token $token)
  28.     {
  29.         @trigger_error('The spaceless tag is deprecated since Twig 2.7, use the spaceless filter instead.'E_USER_DEPRECATED);
  30.         $lineno $token->getLine();
  31.         $this->parser->getStream()->expect(/* Token::BLOCK_END_TYPE */ 3);
  32.         $body $this->parser->subparse([$this'decideSpacelessEnd'], true);
  33.         $this->parser->getStream()->expect(/* Token::BLOCK_END_TYPE */ 3);
  34.         return new SpacelessNode($body$lineno$this->getTag());
  35.     }
  36.     public function decideSpacelessEnd(Token $token)
  37.     {
  38.         return $token->test('endspaceless');
  39.     }
  40.     public function getTag()
  41.     {
  42.         return 'spaceless';
  43.     }
  44. }
  45. class_alias('Twig\TokenParser\SpacelessTokenParser''Twig_TokenParser_Spaceless');