Skip to content

Instantly share code, notes, and snippets.

@Arwid
Created December 9, 2011 23:34
Show Gist options
  • Save Arwid/1453823 to your computer and use it in GitHub Desktop.
Save Arwid/1453823 to your computer and use it in GitHub Desktop.
Compile and Compress a "<fileName>.html.mustache.php" file
<?
function compress($buffer) {
/* remove comments */
$buffer = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $buffer);
/* remove tabs, spaces, newlines, etc. */
$buffer = str_replace(array("\r\n", "\r", "\n", "\t", ' ', ' ', ' '), '', $buffer);
return $buffer;
}
function getTemplate($filename) {
ob_start();
require($filename);
$contents = ob_get_contents();
ob_end_clean();
$compressed = compress($contents);
return $compressed;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment