summaryrefslogtreecommitdiff
path: root/inc/template.php
diff options
context:
space:
mode:
authorSavetheinternet <savetheinternet@tinyboard.org>2011-11-16 16:01:02 +1100
committerSavetheinternet <savetheinternet@tinyboard.org>2011-11-16 16:01:02 +1100
commit27dde88e15d9b978197653b4daa1264b25105660 (patch)
treecc9b7050b1c5ebf964b9ce02558b9835e41bdc90 /inc/template.php
parent8c97d15424e810fceba7688646c9c06ce55c0a58 (diff)
Added config option to automatically remove unnecessary whitespace when compiling HTML files from templates
Diffstat (limited to 'inc/template.php')
-rw-r--r--inc/template.php10
1 files changed, 8 insertions, 2 deletions
diff --git a/inc/template.php b/inc/template.php
index 39d30207..9c61ae15 100644
--- a/inc/template.php
+++ b/inc/template.php
@@ -28,7 +28,7 @@
unset($debug['start']);
}
- $options['body'] .= '<h3>Debug</h3><pre style="white-space: pre-wrap;font-size: 10px;">' . print_r($debug, true) . '</pre><hr/>';
+ $options['body'] .= '<h3>Debug</h3><pre style="white-space: pre-wrap;font-size: 10px;">' . str_replace("\n", '<br/>', print_r($debug, true)) . '</pre><hr/>';
}
$loader->setPaths($config['dir']['template']);
@@ -43,7 +43,13 @@
// Read the template file
if(@file_get_contents("{$config['dir']['template']}/${templateFile}")) {
- return $twig->render($templateFile, $options);
+ $body = $twig->render($templateFile, $options);
+
+ if($config['minify_html']) {
+ $body = trim(preg_replace("/[\t\r\n]/", '', $body));
+ }
+
+ return $body;
} else {
throw new Exception("Template file '${templateFile}' does not exist or is empty in '{$config['dir']['template']}'!");
}