How can I minify all output HTML templates in Smarty?
like this way:
$smarty->minify = true;
P.S : I found {strip}
function but I should use this function in all of my .tpl
files. I have many .tpl
file and this way is not possible for me.
I used this code:
function minify_html($tpl_output, Smarty_Internal_Template $template) {
$tpl_output = preg_replace('![\t ]*[\r\n]+[\t ]*!', '', $tpl_output);
return $tpl_output;
}
// register the outputfilter
$smarty->registerFilter("output", "minify_html");
$smarty->display($template);
NOTE: you will need to change // comments
into SCRIPT tags to /* comments */
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With