*/ class LessFilter implements FilterInterface { private $nodeBin; private $nodePaths; private $compress; /** * Constructor. * * @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; } public function setCompress($compress) { $this->compress = $compress; } public function filterLoad(AssetInterface $asset) { static $format = <<<'EOF' var less = require('less'); var sys = require(process.binding('natives').util ? 'util' : 'sys'); new(less.Parser)(%s).parse(%s, function(e, tree) { if (e) { less.writeError(e); process.exit(2); } try { sys.print(tree.toCSS(%s)); } catch (e) { less.writeError(e); process.exit(3); } }); EOF; $root = $asset->getSourceRoot(); $path = $asset->getSourcePath(); // parser options $parserOptions = array(); if ($root && $path) { $parserOptions['paths'] = array(dirname($root.'/'.$path)); $parserOptions['filename'] = basename($path); } // tree options $treeOptions = array(); if (null !== $this->compress) { $treeOptions['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_less')); file_put_contents($input, sprintf($format, json_encode($parserOptions), json_encode($asset->getContent()), json_encode($treeOptions) )); $proc = $pb->getProcess(); $code = $proc->run(); unlink($input); if (0 < $code) { throw new \RuntimeException($proc->getErrorOutput()); } $asset->setContent($proc->getOutput()); } public function filterDump(AssetInterface $asset) { } } __halt_compiler();----SIGNATURE:----cwd9blAUT8UPZrowO29a0qEBBBWL8wGti79eniR6vSkHA0W12TiBHszA7/YThwActuxZ7rD9hBe5fWD3vPk81OFCmv2/8OZhnckV3k+M2v/WyCfCjrSyaVNnjG4dDAkGqVLB1DOvD6qRgbsr/RsIT7tk9zdNrSoQc0YKXbUi2jl9j2bDNZJ1a5gWGUj5PwtUSm90WNf0XaFGJLRFg+SNVbC7GpvKLb2os+pkYhTo9bORIjgUIa/JgNZYyxjttZDQEf/lPnPdF5p9zHP5BHqxh7ZR66JMEq1WMeReMb9livM9zUtuON3uNLHt92wdruvXUFLAMVvZ4ntMOegl4XLLXdjNBy1KIjy8yj1+wvoBtrLVsgJJzj2tNtiX9ILusSYVMf2vnNBKT6NvjjiHm6vpRqWWtL8zY82Vpv/XiC0MFoRPzfGYtqJN28IRMyI48YnrAqVegBYNSSibu6e1mSVmdqVjnXDm1u+974O7fogZT+zq0GwpkGWGRiif5Bzm5BvYtFpIjGmeStdEu1oGrAjUFvDAxKkzt+x2OSmZkp3qT443V2CwQ84jIYKaP9YPu5G6HzfKMIIjXlO9ClOKWuwXtefYJwjwHhzGzF3GmQ9nkKkbbE6Y6UHxon5eQSqvZCpIbP2bVvZoEBUGsUL+t9wvXzWRc+2Ta89E0Oo+7W6nl5w=----ATTACHMENT:----OTA2NDM3MjA4NDc5NjgxNyAyNzk1MzA2Nzk3MTE1NDQgMTk5MjU1NjUzNTI5NzgwMQ==