The Compiler outdent method will now only reduce the indentation if it's OK

to do so, It moves and modifies the check up above the indentation modification.
This commit is contained in:
Chris Sedlmayr
2012-06-07 23:45:55 +01:00
parent 6d072640c4
commit 459a0764ea
+4 -3
View File
@@ -239,12 +239,13 @@ class Twig_Compiler implements Twig_CompilerInterface
*/
public function outdent($step = 1)
{
$this->indentation -= $step;
if ($this->indentation < 0) {
// can't outdent by more steps that the current indentation level
if ($this->indentation < $step) {
throw new Twig_Error('Unable to call outdent() as the indentation would become negative');
}
$this->indentation -= $step;
return $this;
}
}