Revision 1852
Added by darkviper over 11 years ago
If.php | ||
---|---|---|
36 | 36 |
{ |
37 | 37 |
$lineno = $token->getLine(); |
38 | 38 |
$expr = $this->parser->getExpressionParser()->parseExpression(); |
39 |
$this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE); |
|
39 |
$stream = $this->parser->getStream(); |
|
40 |
$stream->expect(Twig_Token::BLOCK_END_TYPE); |
|
40 | 41 |
$body = $this->parser->subparse(array($this, 'decideIfFork')); |
41 | 42 |
$tests = array($expr, $body); |
42 | 43 |
$else = null; |
43 | 44 |
|
44 | 45 |
$end = false; |
45 | 46 |
while (!$end) { |
46 |
switch ($this->parser->getStream()->next()->getValue()) {
|
|
47 |
switch ($stream->next()->getValue()) {
|
|
47 | 48 |
case 'else': |
48 |
$this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE);
|
|
49 |
$stream->expect(Twig_Token::BLOCK_END_TYPE);
|
|
49 | 50 |
$else = $this->parser->subparse(array($this, 'decideIfEnd')); |
50 | 51 |
break; |
51 | 52 |
|
52 | 53 |
case 'elseif': |
53 | 54 |
$expr = $this->parser->getExpressionParser()->parseExpression(); |
54 |
$this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE);
|
|
55 |
$stream->expect(Twig_Token::BLOCK_END_TYPE);
|
|
55 | 56 |
$body = $this->parser->subparse(array($this, 'decideIfFork')); |
56 | 57 |
$tests[] = $expr; |
57 | 58 |
$tests[] = $body; |
... | ... | |
62 | 63 |
break; |
63 | 64 |
|
64 | 65 |
default: |
65 |
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), -1);
|
|
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());
|
|
66 | 67 |
} |
67 | 68 |
} |
68 | 69 |
|
69 |
$this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE);
|
|
70 |
$stream->expect(Twig_Token::BLOCK_END_TYPE);
|
|
70 | 71 |
|
71 | 72 |
return new Twig_Node_If(new Twig_Node($tests), $else, $lineno, $this->getTag()); |
72 | 73 |
} |
Also available in: Unified diff
updated Twig template engine to stable version 1.11.1 step2