Skip to content

Instantly share code, notes, and snippets.

@enumag
Created February 16, 2012 21:23
Show Gist options
  • Save enumag/1847959 to your computer and use it in GitHub Desktop.
Save enumag/1847959 to your computer and use it in GitHub Desktop.
ISS helper
/**
* @param string
* @param string
* @return bool
*/
function issCheck($dir, $out) {
if (!file_exists($out)) {
return TRUE;
}
$time = filemtime($out);
$it = new DirectoryIterator($dir);
foreach ($it as $file) {
if ($file->isFile() && $file->getMTime() > $time) {
return TRUE;
}
}
}
/**
* @param string
* @return string
*/
function issCompile($in) {
$out = '/cache/css/' . pathinfo($in, PATHINFO_FILENAME) . '.css';
if (issCheck(dirname($in), __DIR__ . $out)) {
$ivory = new \Ivory\StyleSheets\Compiler();
$ivory->outputDirectory = __DIR__ . '/cache/css/';
$ivory->setDefaultUnit('px');
$ivory->compileFile($in);
}
return $out;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment