better templating
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user