Skip to content

Commit

Permalink
Merge pull request #1 from stupidlysimple/nightly
Browse files Browse the repository at this point in the history
0.5.0
  • Loading branch information
Fariz Luqman committed Feb 24, 2017
2 parents 7017caf + cc60bec commit 477ddf9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Debugger.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ static private function microtime_diff($start)
* @since Method available since Release 0.1.0
*/
static function exec_time(){
echo ('<span style="display: table; margin: 0 auto;">Request takes '.(self::microtime_diff(SS_START) * 1000 ) . ' milliseconds</span>');
echo ('<span class="ss_exec_time" style="display: table; margin: 0 auto;">Request takes '.(self::microtime_diff(SS_START) * 1000 ) . ' milliseconds</span>');
}

static function startProfiling(){
Expand Down
20 changes: 17 additions & 3 deletions src/Viewer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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]];
}
}

}

0 comments on commit 477ddf9

Please sign in to comment.