From 7a8dd0b67c207516ee6c4d597002e26574f5811f Mon Sep 17 00:00:00 2001 From: Kevin Chabowski Date: Sat, 24 May 2014 01:26:33 +0200 Subject: Fixed parsing variables If a variable was the very last thing in a template, the last charater of the variable was duplicated as a text node. --- Parser.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Parser.php b/Parser.php index 1ca0798..e3b8d07 100644 --- a/Parser.php +++ b/Parser.php @@ -34,6 +34,9 @@ class Parser { return $c; } + private function eof() { + return ($this->off == $this->len); + } private function back($n = 1) { if($n <= 0) { @@ -349,7 +352,9 @@ class Parser { private function parse_var($openedat, $curly) { $varnode = new VariableNode($this->name, $openedat); $varnode->name = $this->get_name(); - $varnode->arrayfields = $this->parse_array(); + if(!$this->eof()) { + $varnode->arrayfields = $this->parse_array(); + } if(($curly) && ($this->next() != "}")) { throw new ParseCompileError("Unclosed '\${'", $this->name, $openedat); -- cgit v1.2.3-70-g09d2