Skip to content

Instantly share code, notes, and snippets.

@absfarah
Created May 15, 2012 10:45
Show Gist options
  • Save absfarah/2700756 to your computer and use it in GitHub Desktop.
Save absfarah/2700756 to your computer and use it in GitHub Desktop.
<?php
#require_once APPPATH . 'classes/helpers/autoload.php';
error_reporting(E_ALL);
use ju1ius\Html\EmailPreflight;
class Inliner {
public function inline($html_path) {
spl_autoload_extensions('.php');
spl_autoload_register('Inliner::myAutoLoad');
libxml_use_internal_errors(true);
$options = array('strict_parsing' => true, 'css' => array('to_html_attributes' => false),
'html' => array(
'remove_styles' => false,
'remove_classes' => false,
'remove_ids' => false,
'remove_comments' => false,
'remove_whitespace' => false
));
$inline = new EmailPreflight($options);
$inline->loadHtmlFile($html_path);
$inline->inlineCss();
$html = $inline->toHtml();
spl_autoload_unregister('Inliner::myAutoLoad');
return $html;
}
function myAutoLoad($name) {
@include_once(str_replace('\\', '/', trim($name, '\\')) . '.php');
}
}
$a = new Inliner();
$html = $a->inline('C:\svn\test\ju\5-goodyear.html');
echo $html;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment