} } class ProcessorJSX extends ExternalProcessor { protected function getCommandLine($filename, $opts = array()) { if (!is_executable(SACY_TRANSFORMER_JSX)) { throw new Exception('SACY_TRANSFORMER_JSX defined but not executable'); } return SACY_TRANSFORMER_JSX; } } if (defined('SACY_COMPRESSOR_UGLIFY')) { ExternalProcessorRegistry::registerCompressor('text/javascript', 'sacy\\ProcessorUglify'); } if (defined('SACY_TRANSFORMER_COFFEE')) { ExternalProcessorRegistry::registerTransformer('text/coffeescript', 'sacy\\ProcessorCoffee'); } if (defined('SACY_TRANSFORMER_ECO')) { ExternalProcessorRegistry::registerTransformer('text/x-eco', 'sacy\\ProcessorEco'); } if (defined('SACY_TRANSFORMER_SASS')) { ExternalProcessorRegistry::registerTransformer('text/x-sass', 'sacy\\ProcessorSass'); ExternalProcessorRegistry::registerTransformer('text/x-scss', 'sacy\\ProcessorScss'); } if (defined('SACY_TRANSFORMER_LESS')) { ExternalProcessorRegistry::registerTransformer('text/x-less', 'sacy\\ProcessorLess'); } if (defined('SACY_TRANSFORMER_JSX')) { ExternalProcessorRegistry::registerTransformer('text/x-jsx', 'sacy\\ProcessorJSX'); }
function getOutput($work_unit) { $debug = $this->getConfig()->getDebugMode() == 3; if ($work_unit['file']) { $css = @file_get_contents($work_unit['file']); if (!$css) { return "/* error accessing file */"; } $source_file = $work_unit['file']; } else { $css = $work_unit['content']; $source_file = $this->getSourceFile(); } if (ExternalProcessorRegistry::typeIsSupported($work_unit['type'])) { $opts = array(); if ($work_unit['paths']) { $opts['library_path'] = $work_unit['paths']; } $css = ExternalProcessorRegistry::getTransformerForType($work_unit['type'])->transform($css, $source_file, $opts); } else { if ($work_unit['type'] == 'text/x-less') { $less = new \lessc(); $less->importDir = dirname($source_file) . '/'; #lessphp concatenates without a / $css = $less->parse($css); } if (PhpSassSacy::isAvailable() && $work_unit['type'] == 'text/x-scss') { $css = PhpSassSacy::compile($source_file, $work_unit['paths'] ?: array(dirname($source_file))); } elseif (in_array($work_unit['type'], array('text/x-scss', 'text/x-sass'))) { $config = array('cache' => false, 'debug_info' => $debug, 'line' => $debug, 'load_paths' => $work_unit['paths'] ?: array(dirname($source_file)), 'filename' => $source_file, 'quiet' => true, 'style' => $debug ? 'nested' : 'compressed'); $sass = new \SassParser($config); $css = $sass->toCss($css, false); // isFile? } } if ($debug) { return \Minify_CSS_UriRewriter::rewrite($css, dirname($source_file), $this->getConfig()->getDocumentRoot(), array()); } else { return \Minify_CSS::minify($css, array('currentDir' => dirname($source_file), 'docRoot' => $this->getConfig()->getDocumentRoot())); } }
protected function getType() { return 'text/x-scss'; } } class ProcessorLess extends ExternalProcessor { protected function getCommandLine($filename, $opts = array()) { if (!is_executable(SACY_TRANSFORMER_LESS)) { throw new \Exception('SACY_TRANSFORMER_LESS defined but not executable'); } return sprintf('%s -I%s -', SACY_TRANSFORMER_LESS, escapeshellarg(dirname($filename))); } } if (defined('SACY_COMPRESSOR_UGLIFY')) { ExternalProcessorRegistry::registerCompressor('text/javascript', 'sacy\\ProcessorUglify'); } if (defined('SACY_TRANSFORMER_COFFEE')) { ExternalProcessorRegistry::registerTransformer('text/coffeescript', 'sacy\\ProcessorCoffee'); } if (defined('SACY_TRANSFORMER_ECO')) { ExternalProcessorRegistry::registerTransformer('text/x-eco', 'sacy\\ProcessorEco'); } if (defined('SACY_TRANSFORMER_SASS')) { ExternalProcessorRegistry::registerTransformer('text/x-sass', 'sacy\\ProcessorSass'); ExternalProcessorRegistry::registerTransformer('text/x-scss', 'sacy\\ProcessorScss'); } if (defined('SACY_TRANSFORMER_LESS')) { ExternalProcessorRegistry::registerTransformer('text/x-less', 'sacy\\ProcessorLess'); }