diff --git a/Lib/Formatter/Html.php b/Lib/Formatter/Html.php index 2d1270d..f9e61eb 100644 --- a/Lib/Formatter/Html.php +++ b/Lib/Formatter/Html.php @@ -97,12 +97,14 @@ class Html extends Formatter { ); } - $html = file_get_contents('template.html'); + $panel = static::template($context, 'panel'); + echo static::template(array('title' => $context['title'], 'content' => $panel)); + } - foreach($context as $k => $v) { - $html = str_replace("{{ $k }}", $v, $html); - } + public static function template(array $context = array(), $template = 'layout') { + $html = file_get_contents(sprintf('templates/%s.html', $template)); - echo $html; + $patterns = array_map(function($p) { return "{{ $p }}"; }, array_keys($context)); + return str_replace($patterns, array_values($context), $html); } } diff --git a/template.html b/templates/layout.html similarity index 84% rename from template.html rename to templates/layout.html index 3430264..55195f7 100644 --- a/template.html +++ b/templates/layout.html @@ -30,14 +30,7 @@