protected $regexes;
protected $position;
protected $positions;
+ protected $currentVarBlockLine;
const STATE_DATA = 0;
const STATE_BLOCK = 1;
} else {
$this->pushToken(Twig_Token::BLOCK_START_TYPE);
$this->pushState(self::STATE_BLOCK);
+ $this->currentVarBlockLine = $this->lineno;
}
break;
case $this->options['tag_variable'][0]:
$this->pushToken(Twig_Token::VAR_START_TYPE);
$this->pushState(self::STATE_VAR);
+ $this->currentVarBlockLine = $this->lineno;
break;
}
}
$this->moveCursor($match[0]);
if ($this->cursor >= $this->end) {
- throw new Twig_Error_Syntax(sprintf('Unexpected end of file: Unclosed "%s"', $this->state === self::STATE_BLOCK ? 'block' : 'variable'), $this->lineno, $this->filename);
+ throw new Twig_Error_Syntax(sprintf('Unclosed "%s"', $this->state === self::STATE_BLOCK ? 'block' : 'variable'), $this->currentVarBlockLine, $this->filename);
}
}
$stream->expect(Twig_Token::NUMBER_TYPE, 1);
$stream->expect(Twig_Token::OPERATOR_TYPE, 'and');
}
+
+ /**
+ * @expectedException Twig_Error_Syntax
+ * @expectedExceptionMessage Unclosed "variable" at line 3
+ */
+ public function testUnterminatedVariable()
+ {
+ $template = '
+
+{{
+
+bar
+
+
+';
+
+ $lexer = new Twig_Lexer(new Twig_Environment());
+ $stream = $lexer->tokenize($template);
+ }
+
+ /**
+ * @expectedException Twig_Error_Syntax
+ * @expectedExceptionMessage Unclosed "block" at line 3
+ */
+ public function testUnterminatedBlock()
+ {
+ $template = '
+
+{%
+
+bar
+
+
+';
+
+ $lexer = new Twig_Lexer(new Twig_Environment());
+ $stream = $lexer->tokenize($template);
+ }
}