Better handle parse errors in nested templates
authorRobert Sesek <rsesek@bluestatic.org>
Thu, 26 Jun 2008 16:10:50 +0000 (12:10 -0400)
committerRobert Sesek <rsesek@bluestatic.org>
Thu, 26 Jun 2008 16:10:50 +0000 (12:10 -0400)
* Template.php:
(BSTemplate::evaluate): Don't call ob_end_clean()

CHANGES
Template.php

diff --git a/CHANGES b/CHANGES
index cbc06aab47e531416e4f98eb77b022108dd5b9dc..de494b6595fa41d18b00275257238018910cd5a9 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -11,3 +11,4 @@
 - New: Implement Iterator in BSDBResult
 - New: In the BSTemplate::$preParseHook method, the second parameter will be the BSTemplate object itself
 - New: Add BSTemplate::$globalVars to be substituted into every template
+- Change: BSTemplate will better detect parse errors in nested templates in BSTemplate::evaluate()
index 2a03747cec333fdf13ff1416f5c72a3b5cebef4d..1d90c7246a26d857ee61e73585ae2ec3e816fae5 100644 (file)
@@ -197,9 +197,14 @@ class BSTemplate
                ob_start();
                $this->template = str_replace(array('$this->', 'self::'), 'null', $this->template); // don't want internal access coming from a template
                $this->template = '?>' . $this->template;
-               eval($this->template);
-               $this->template = ob_get_clean();
-               ob_end_clean();
+               $test = eval($this->template);
+               $output = ob_get_clean();               
+               if ($output === false)
+               {
+                       throw new Exception('A parse error was encountered while evaluating the template');
+               }
+               
+               $this->template = $output;
                
                return $this;
        }