mirror of
https://github.com/monstra-cms/monstra.git
synced 2025-08-08 22:26:55 +02:00
New Minify Classes!
This commit is contained in:
47
libraries/Gelato/Minify/MinifyHTML.php
Normal file
47
libraries/Gelato/Minify/MinifyHTML.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Gelato Library
|
||||
*
|
||||
* This source file is part of the Gelato Library. More information,
|
||||
* documentation and tutorials can be found at http://gelato.monstra.org
|
||||
*
|
||||
* @package Gelato
|
||||
*
|
||||
* @author Romanenko Sergey / Awilum <awilum@msn.com>
|
||||
* @copyright 2012-2013 Romanenko Sergey / Awilum <awilum@msn.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
class MinifyHTML
|
||||
{
|
||||
/**
|
||||
* Minify html
|
||||
*
|
||||
* <code>
|
||||
* echo MinifyHTML::process($html);
|
||||
* </code>
|
||||
*
|
||||
* @param string $buffer html
|
||||
* @return string
|
||||
*/
|
||||
public static function process($html)
|
||||
{
|
||||
// Remove HTML comments (not containing IE conditional comments).
|
||||
$html = preg_replace_callback('/<!--([\\s\\S]*?)-->/', 'self::_comments', $html);
|
||||
|
||||
// Trim each line.
|
||||
$html = preg_replace('/^\\s+|\\s+$/m', '', $html);
|
||||
|
||||
// Return HTML
|
||||
return $html;
|
||||
}
|
||||
|
||||
protected static function _comments($m)
|
||||
{
|
||||
return (0 === strpos($m[1], '[') || false !== strpos($m[1], '<![')) ? $m[0] : '';
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user