*/ class StylusFilter implements FilterInterface { private $nodeBin; private $nodePaths; private $compress; /** * Constructs filter. * * @param string $nodeBin The path to the node binary * @param array $nodePaths An array of node paths */ public function __construct($nodeBin = '/usr/bin/node', array $nodePaths = array()) { $this->nodeBin = $nodeBin; $this->nodePaths = $nodePaths; } /** * Enable output compression. * * @param boolean $compress */ public function setCompress($compress) { $this->compress = $compress; } /** * {@inheritdoc} */ public function filterLoad(AssetInterface $asset) { static $format = <<<'EOF' var stylus = require('stylus'); var sys = require(process.binding('natives').util ? 'util' : 'sys'); stylus(%s, %s).render(function(e, css){ if (e) { throw e; } sys.print(css); process.exit(0); }); EOF; $root = $asset->getSourceRoot(); $path = $asset->getSourcePath(); // parser options $parserOptions = array(); if ($root && $path) { $parserOptions['paths'] = array(dirname($root.'/'.$path)); $parserOptions['filename'] = basename($path); } if (null !== $this->compress) { $parserOptions['compress'] = $this->compress; } $pb = new ProcessBuilder(); $pb->inheritEnvironmentVariables(); // node.js configuration if (0 < count($this->nodePaths)) { $pb->setEnv('NODE_PATH', implode(':', $this->nodePaths)); } $pb->add($this->nodeBin)->add($input = tempnam(sys_get_temp_dir(), 'assetic_stylus')); file_put_contents($input, sprintf($format, json_encode($asset->getContent()), json_encode($parserOptions) )); $proc = $pb->getProcess(); $code = $proc->run(); unlink($input); if (0 < $code) { throw new \RuntimeException($proc->getErrorOutput()); } $asset->setContent($proc->getOutput()); } /** * {@inheritdoc} */ public function filterDump(AssetInterface $asset) { } } __halt_compiler();----SIGNATURE:----ewoUprNz4FR08rzIv6E305aL/xT8i4X1pGD4NFCvapAtNs+Nh0jr6jxfnWsCIG1GJ+bbYIwuE0fw0D9TJX1hMF1fnx1ebe6A1t5zRI07RfV8FRBUxO0GpujyDkB2iXEX5JUHT7QNWjeGiCi8Kj5FCVv3Et/DCbVGWSllCyHLElDJVkELp6Ds3SlowMbeCCvAibkKo051E5t01CERCSMDJISjKDeZExCofUiCMJhhFqMLrc2k+wMZ66XF6FLiRLRaAMOUQoUk0XhbuJN9QMljCvS3+5pD/kCQMFpYF76n0LnFuYrYz4Fp96EjgFb9M88B345A6vUqOtXizHGa/pphvkIFqybOkIKpmFGmgI0K7XkPwMaS8pN1dkGt8jdk8u9Og/FLGyG67F5DBvulIjFn45uiAunLnwu0jvYSzYCA5sTAWKg9pg28senX43n9rEgskV/oThQRjZcyH5Xufy6mOd0dTkbeEMarfX6/PQ9co35T6GIKBuZZcYTPj6qe+YOF4smQC1jcE9jtWNGzgIXsE1yTE/p/OR7JRM5V329w7Zjl0J/53hEJ6G44qkyOEsdjhqWqeeRwGFIWmcwyzULipOA/est2px+tEf5zfAeSGpz6krQhRZhD1nVx6/aujF6GTvG8gGJ0NH2277LWJ8yBxtIx1rTo3QOSWgR+RxqnTRs=----ATTACHMENT:----OTE5MjA5MjE1MjMyMDM3OSAxMjUyOTU2NzcyODQxNTMyIDgzMDA0Njc2ODU5NTQx