Skip to content
Browse files

updating View class to scope in the inclusion of the template

  • Loading branch information...
1 parent 7d29d9d commit 1c3b23e38030308781bfbc5702da67e6a101b76d @enygma committed Aug 10, 2012
Showing with 15 additions and 4 deletions.
  1. +15 −4 Shield/View.php
View
19 Shield/View.php
@@ -202,10 +202,21 @@ public function render($template)
}
if (is_file($templateFile)) {
- extract($this->_properties);
- ob_start();
- include_once $templateFile;
- return ob_get_clean();
+
+ // scope in the tempate extraction
+ $result = function($file,array $data=array()) {
+ ob_start();
+ extract($this->_properties);
+ try {
+ include $file;
+ } catch(\Exception $e) {
+ ob_end_clean();
+ throw $e;
+ }
+ return ob_get_clean();
+ };
+
+ return $result($templateFile, $this->_properties);
} else {
// it's just a string! fall back on str_replace

0 comments on commit 1c3b23e

Please sign in to comment.
Something went wrong with that request. Please try again.