Skip to content

Instantly share code, notes, and snippets.

@ericboehs
Created January 18, 2010 19:25
Show Gist options
  • Select an option

  • Save ericboehs/280281 to your computer and use it in GitHub Desktop.

Select an option

Save ericboehs/280281 to your computer and use it in GitHub Desktop.
<?php
$file = 'test.tpl';
preg_match_all('/(?!{compress name=.*})[^}{]+?(?={\/compress})/',file_get_contents($file), $compress_blocks);
$compress_blocks = array_map('trim', $compress_blocks[0]);
foreach($compress_blocks as $compress_block){
$compress_block = '<?xml version="1.0" encoding="ISO-8859-1"?>'.'<xml>'.$compress_block."</xml>";
$xmlDoc = new DOMDocument();
$xmlDoc->loadXML($compress_block);
$x = $xmlDoc->documentElement;
foreach($x->childNodes as $item){
if($item->nodeName == "link")
$css_files[$item->getAttribute('media')][] = $item->getAttribute('href');
if($item->nodeName == "script")
$js_files[] = $item->getAttribute('src');
}
unset($xmlDoc);
}
print_r ($css_files);
print_r ($js_files);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment