4 * This file is part of Twig.
6 * (c) 2010 Fabien Potencier
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
13 * Remove whitespaces between HTML tags.
18 * <strong>foo</strong>
22 * {# output will be <div><strong>foo</strong></div> #}
25 class Twig_TokenParser_Spaceless
extends Twig_TokenParser
28 * Parses a token and returns a node.
30 * @param Twig_Token $token A Twig_Token instance
32 * @return Twig_NodeInterface A Twig_NodeInterface instance
34 public function parse(Twig_Token
$token)
36 $lineno = $token->getLine();
38 $this->parser
->getStream()->expect(Twig_Token
::BLOCK_END_TYPE
);
39 $body = $this->parser
->subparse(array($this, 'decideSpacelessEnd'), true);
40 $this->parser
->getStream()->expect(Twig_Token
::BLOCK_END_TYPE
);
42 return new Twig_Node_Spaceless($body, $lineno, $this->getTag());
45 public function decideSpacelessEnd(Twig_Token
$token)
47 return $token->test('endspaceless');
51 * Gets the tag name associated with this token parser.
53 * @return string The tag name
55 public function getTag()