38 $expr = $this->parser->getExpressionParser()->parseExpression();
39 $stream = $this->parser->getStream();
41 $body = $this->parser->subparse(array($this,
'decideIfFork'));
42 $tests = array($expr, $body);
47 switch ($stream->next()->getValue()) {
50 $else = $this->parser->subparse(array($this,
'decideIfEnd'));
54 $expr = $this->parser->getExpressionParser()->parseExpression();
56 $body = $this->parser->subparse(array($this,
'decideIfFork'));
66 throw new Twig_Error_Syntax(sprintf(
'Unexpected end of template. Twig was looking for the following tags "else", "elseif", or "endif" to close the "if" block started at line %d)', $lineno), $stream->getCurrent()->getLine(), $stream->getFilename());
77 return $token->
test(array(
'elseif',
'else',
'endif'));
82 return $token->
test(array(
'endif'));
Base class for all token parsers.
parse(Twig_Token $token)
Parses a token and returns a node.
Represents a node in the AST.
Exception thrown when a syntax error occurs during lexing or parsing of a template.
decideIfEnd(Twig_Token $token)
getTag()
Gets the tag name associated with this token parser.
decideIfFork(Twig_Token $token)
test($type, $values=null)
Tests the current token for a type and/or a value.