diff --git a/src/Debugger.php b/src/Debugger.php
index 9e3a1bd..137e355 100755
--- a/src/Debugger.php
+++ b/src/Debugger.php
@@ -187,7 +187,7 @@ static private function microtime_diff($start)
* @since Method available since Release 0.1.0
*/
static function exec_time(){
- echo ('Request takes '.(self::microtime_diff(SS_START) * 1000 ) . ' milliseconds');
+ echo ('Request takes '.(self::microtime_diff(SS_START) * 1000 ) . ' milliseconds');
}
static function startProfiling(){
diff --git a/src/Viewer.php b/src/Viewer.php
index d4ce661..6088067 100755
--- a/src/Viewer.php
+++ b/src/Viewer.php
@@ -41,6 +41,8 @@
*/
class Viewer {
+ private static $hive;
+
/**
* Finds, renders and displays a template file. Reports a 404 error in
* case of missing files.
@@ -103,11 +105,23 @@ static private function render($file, &$data = []){
extract(Sharer::get());
}
+ // Get all defined vars into $hive, which is used in callback method replace
+ self::$hive = get_defined_vars();
+
ob_start();
- include_once($file);
- $output = ob_get_contents();
+ include($file);
+ $input = ob_get_contents();
ob_end_clean();
- echo ($output);
+
+ $output = preg_replace_callback('!\{\{(\w+)\}\}!', 'Viewer::replace', $input);
+
+ echo($output);
}
+ static private function replace($matches) {
+ if(isset(self::$hive[$matches[1]])){
+ return self::$hive[$matches[1]];
+ }
+ }
+
}