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

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 with the "apply" tag instead)
  24.  */
  25. final class SpacelessTokenParser extends AbstractTokenParser
  26. {
  27.     public function parse(Token $token)
  28.     {
  29.         $stream $this->parser->getStream();
  30.         $lineno $token->getLine();
  31.         @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);
  32.         $stream->expect(/* Token::BLOCK_END_TYPE */ 3);
  33.         $body $this->parser->subparse([$this'decideSpacelessEnd'], true);
  34.         $stream->expect(/* Token::BLOCK_END_TYPE */ 3);
  35.         return new SpacelessNode($body$lineno$this->getTag());
  36.     }
  37.     public function decideSpacelessEnd(Token $token)
  38.     {
  39.         return $token->test('endspaceless');
  40.     }
  41.     public function getTag()
  42.     {
  43.         return 'spaceless';
  44.     }
  45. }
  46. class_alias('Twig\TokenParser\SpacelessTokenParser''Twig_TokenParser_Spaceless');