ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Twig_TokenParser_Spaceless Class Reference

Remove whitespaces between HTML tags. More...

+ Inheritance diagram for Twig_TokenParser_Spaceless:
+ Collaboration diagram for Twig_TokenParser_Spaceless:

Public Member Functions

 parse (Twig_Token $token)
 Parses a token and returns a node. More...
 
 decideSpacelessEnd (Twig_Token $token)
 
 getTag ()
 Gets the tag name associated with this token parser. More...
 
- Public Member Functions inherited from Twig_TokenParser
 setParser (Twig_Parser $parser)
 Sets the parser associated with this token parser. More...
 

Additional Inherited Members

- Protected Attributes inherited from Twig_TokenParser
 $parser
 

Detailed Description

Remove whitespaces between HTML tags.

{% spaceless %}
     
foo
{% endspaceless %}
{# output will be 
foo
#}

Definition at line 27 of file Spaceless.php.

Member Function Documentation

◆ decideSpacelessEnd()

Twig_TokenParser_Spaceless::decideSpacelessEnd ( Twig_Token  $token)

Definition at line 40 of file Spaceless.php.

References Twig_Token\test().

41  {
42  return $token->test('endspaceless');
43  }
test($type, $values=null)
Tests the current token for a type and/or a value.
Definition: Token.php:70
+ Here is the call graph for this function:

◆ getTag()

Twig_TokenParser_Spaceless::getTag ( )

Gets the tag name associated with this token parser.

Returns
string The tag name

Implements Twig_TokenParserInterface.

Definition at line 45 of file Spaceless.php.

Referenced by parse().

46  {
47  return 'spaceless';
48  }
+ Here is the caller graph for this function:

◆ parse()

Twig_TokenParser_Spaceless::parse ( Twig_Token  $token)

Parses a token and returns a node.

Returns
Twig_NodeInterface
Exceptions
Twig_Error_Syntax

Implements Twig_TokenParserInterface.

Definition at line 29 of file Spaceless.php.

References Twig_Token\BLOCK_END_TYPE, Twig_Token\getLine(), and getTag().

30  {
31  $lineno = $token->getLine();
32 
33  $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE);
34  $body = $this->parser->subparse(array($this, 'decideSpacelessEnd'), true);
35  $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE);
36 
37  return new Twig_Node_Spaceless($body, $lineno, $this->getTag());
38  }
getTag()
Gets the tag name associated with this token parser.
Definition: Spaceless.php:45
Represents a spaceless node.
Definition: Spaceless.php:19
getLine()
Definition: Token.php:87
const BLOCK_END_TYPE
Definition: Token.php:30
+ Here is the call graph for this function:

The documentation for this class was generated from the following file: