diff --git a/Lib/Formatter/Html.php b/Lib/Formatter/Html.php
index 1575a6b..f92c6cb 100644
--- a/Lib/Formatter/Html.php
+++ b/Lib/Formatter/Html.php
@@ -18,12 +18,14 @@ class Html extends Formatter {
$first = reset($data);
$single = ! is_array($first);
- $content = '
';
+ $content = '';
if($single) {
$content .= "| Field | Value |
";
} else {
+ $columns = array_keys($first);
+
$content .= '';
- foreach(array_keys($first) as $k) {
+ foreach($columns as $k) {
$content .= "| $k | ";
}
$content .= '
';
@@ -36,8 +38,14 @@ class Html extends Formatter {
} else {
foreach($data as $row) {
$content .= '';
- foreach($row as $col) {
- $content .= '| '.print_r($col, true).' | ';
+ foreach($columns as $c) {
+ $v = print_r(isset($row[$c]) ? $row[$c] : '', true);
+
+ $limit = 50;
+ if(strlen($v) > $limit) {
+ $v = substr($v, 0, $limit).' [...]';
+ }
+ $content .= "$v | ";
}
$content .= '
';
}
@@ -75,6 +83,17 @@ class Html extends Formatter {
$content = 'Unable to render this
';
}
- echo $content;
+ $html = file_get_contents('template.html');
+
+ $context = array(
+ 'title' => 'BSR - WebService',
+ 'content' => $content
+ );
+
+ foreach($context as $k => $v) {
+ $html = str_replace("{{ $k }}", $v, $html);
+ }
+
+ echo $html;
}
}
diff --git a/template.html b/template.html
new file mode 100644
index 0000000..210b161
--- /dev/null
+++ b/template.html
@@ -0,0 +1,15 @@
+
+
+
+
+ BSR WebService - {{ title }}
+
+
+
+
+ {{ content }}
+
+
+
+
+
\ No newline at end of file