/** * Filters an asset after it has been loaded. * * @param \Assetic\Asset\AssetInterface $asset * @return void */ public function filterLoad(AssetInterface $asset) { $max_nesting_level = ini_get('xdebug.max_nesting_level'); $memory_limit = ini_get('memory_limit'); if ($max_nesting_level && $max_nesting_level < 200) { ini_set('xdebug.max_nesting_level', 200); } if ($memory_limit && $memory_limit < 256) { ini_set('memory_limit', '256M'); } $root = $asset->getSourceRoot(); $path = $asset->getSourcePath(); $dirs = array(); $lc = new \Less_Parser(array('compress' => true)); if ($root && $path) { $dirs[] = dirname($root . '/' . $path); } foreach ($this->loadPaths as $loadPath) { $dirs[] = $loadPath; } $lc->SetImportDirs($dirs); $url = parse_url($this->getRequest()->getUriForPath('')); $absolutePath = str_replace(public_path(), '', $root); if (isset($url['path'])) { $absolutePath = $url['path'] . $absolutePath; } $lc->parseFile($root . '/' . $path, $absolutePath); $asset->setContent($lc->getCss()); }
public function dump(AssetInterface $asset) { $writer = new \Assetic\AssetWriter(sys_get_temp_dir(), $this->container->getParameter('assetic.variables')); $ref = new \ReflectionMethod($writer, 'getCombinations'); $ref->setAccessible(true); $name = $asset->getSourcePath(); $type = substr($name, strrpos($name, '.') + 1); switch ($type) { case 'coffee': $asset->ensureFilter($this->container->get('assetic.filter.coffee')); $type = 'js'; break; case 'less': $asset->ensureFilter($this->container->get('assetic.filter.less')); $type = 'css'; break; } $combinations = $ref->invoke($writer, $asset->getVars()); $asset->setValues($combinations[0]); $asset->load(); $content = $asset->getContent(); // because the assetic cssrewrite makes bullshit here, we need to reimplement the filter if ($type === 'css') { $content = $this->cssFilter($content, '/' . dirname($asset->getSourcePath())); } return $content; }
/** * {@inheritdoc} */ public function filterDump(AssetInterface $asset) { if (preg_match('/\\.yfp\\.js$/', $asset->getSourcePath())) { $content = $asset->getContent(); preg_match('/(\\w+)\\.yfp\\.js$/', $asset->getSourcePath(), $matches); if (isset($matches[1])) { $name = $matches[1]; $pluginName = str_replace(' ', '', ucwords(strtr($matches[1], '_-', ' '))); $config = []; if ($this->parameterBag->has("ynlo.js_plugin.{$name}")) { $config = $this->parameterBag->get("ynlo.js_plugin.{$name}"); } $jsonConfig = json_encode($config, JSON_FORCE_OBJECT); $autoRegister = null; if (strpos($content, "YnloFramework.register('{$pluginName}')") === false && strpos($content, "YnloFramework.register(\"{$pluginName}\\')") === false) { $autoRegister = "\nYnloFramework.register('{$pluginName}');"; } $settings = <<<JAVASCRIPT {$autoRegister} YnloFramework.{$pluginName}.config = \$.extend({}, YnloFramework.{$pluginName}.config, {$jsonConfig}); JAVASCRIPT; $asset->setContent($content . $settings); } } }
/** * Filters an asset after it has been loaded. * * @param AssetInterface $asset An asset */ public function filterLoad(AssetInterface $asset) { if ($this->str_endswith($asset->getSourcePath(), ['.less'])) { $file = Less_Cache::Get([$asset->getSourceRoot() . DIRECTORY_SEPARATOR . $asset->getSourcePath() => '/'], $this->options); if (is_readable($this->options['cache_dir'] . DIRECTORY_SEPARATOR . $file)) { $asset->setContent(file_get_contents($this->options['cache_dir'] . DIRECTORY_SEPARATOR . $file)); } } }
/** * Filters an asset after it has been loaded. * * @param AssetInterface $asset An asset */ public function filterLoad(AssetInterface $asset) { $parser = clone $this->parser; $parser->SetOptions($this->options); if ($this->str_endswith($asset->getSourcePath(), ['.less'])) { $parser->parseFile($asset->getSourceRoot() . DIRECTORY_SEPARATOR . $asset->getSourcePath()); $asset->setContent($parser->getCss()); } }
/** * Filters an asset after it has been loaded. * * @param AssetInterface $asset An asset */ public function filterLoad(AssetInterface $asset) { if ($this->str_endswith($asset->getSourcePath(), ['.js'])) { $moduleName = basename($asset->getSourcePath(), '.js'); $delivery = $this->delivery->create(['includes' => [$asset->getSourceRoot()]]); $delivery->addModule($moduleName); $delivery->setMainModule($moduleName); $asset->setContent($delivery->getOutput()); } }
/** * @param mixed[] $reference * @param AssetInterface $asset * * @return string */ public function rewrite(array $reference, AssetInterface $asset) { if (!$this->isRewritable($reference['url'], $asset->getSourcePath(), $asset->getTargetPath())) { return $reference[0]; } $absoluteSourcePath = $this->getAssetPath(dirname($this->createAssetPath($asset->getSourceRoot(), $asset->getSourcePath())), parse_url($reference['url'])['path']); $webTargetPath = $this->createAssetPath($this->rewriteDirectory, $this->namer->name($absoluteSourcePath, $asset)); $absoluteTargetPath = $this->webDirectory . $webTargetPath; $this->filesystem->{$this->strategy}($absoluteSourcePath, $absoluteTargetPath, true); return str_replace($reference['url'], $this->packages->getUrl($webTargetPath), $reference[0]); }
/** * {@inheritdoc} */ public function filterDump(AssetInterface $asset) { if (preg_match('/pace_settings\\.js$/', $asset->getSourcePath())) { $ajax = $this->config['pace']['ajax'] ? 'true' : 'false'; $document = $this->config['pace']['document'] ? 'true' : 'false'; $eventLag = $this->config['pace']['eventLag'] ? 'true' : 'false'; $restartOnPushState = $this->config['pace']['restartOnPushState'] ? 'true' : 'false'; $restartOnRequestAfter = $this->config['pace']['restartOnRequestAfter'] ? 'true' : 'false'; $settings = <<<JAVASCRIPT var paceOptions = { ajax: {$ajax}, document: {$document}, eventLag: {$eventLag}, restartOnPushState: {$restartOnPushState}, restartOnRequestAfter: {$restartOnRequestAfter}, }; if (typeof requirejs !== 'undefined'){ require(['pace'], function (pace) { pace.start(); }); } JAVASCRIPT; $asset->setContent($settings); } }
/** * {@inheritdoc} */ public function filterDump(AssetInterface $asset) { if (preg_match('/jquery_plugins_overrides\\.js$/', $asset->getSourcePath())) { $content = ''; foreach (AssetRegistry::getAssets() as $module) { if ($module instanceof JavascriptModule && $module->getJqueryPlugins()) { $name = $module->getModuleName(); foreach ($module->getJqueryPlugins() as $method) { $script = <<<JAVASCRIPT //Override {$name} plugin to load with RequireJs \$.fn.{$method} = function () { var element = \$(this); var args = arguments; require(['{$name}'], function (module) { return element.each(function () { \$.fn.{$method}.apply(element,args); }); }); return element; }; JAVASCRIPT; $content .= $script; } $asset->setContent($content); } } } }
/** * {@inheritdoc} */ public function filterDump(AssetInterface $asset) { if (preg_match('/require_js_config\\.js$/', $asset->getSourcePath())) { $config = ['baseUrl' => '/', 'waitSeconds' => false, 'paths' => [], 'shim' => []]; foreach (AssetRegistry::getAssets() as $module) { if ($module instanceof JavascriptModule) { $path = array_key_value($this->config, 'cdn') && $module->getCdn() ? $module->getCdn() : $module->getPath(); $config['paths'][$module->getModuleName()] = preg_replace('/\\.js$/', '', $path); if ($module->getDependencies()) { $config['shim'][$module->getModuleName()]['deps'] = $module->getDependencies(); } if ($module->getExports()) { $config['shim'][$module->getModuleName()]['exports'] = $module->getExports(); } if ($module->getInit()) { $config['shim'][$module->getModuleName()]['init'] = '{function}' . $module->getInit() . '{/function}'; } } } $configJson = json_encode($config, JSON_UNESCAPED_SLASHES); $configJs = str_replace(['"{function}', '{/function}"', '\\"'], ['function(){', '}', '"'], $configJson); $content = <<<EOS require.config({$configJs}); EOS; $asset->setContent($content); } }
/** * Update a given hash with the sha1 hash of an individual asset * * @param AssetInterface $asset * @param $hash */ protected function hashAsset(AssetInterface $asset, $hash) { $sourcePath = $asset->getSourcePath(); $sourceRoot = $asset->getSourceRoot(); $data = $sourcePath && $sourceRoot && file_exists($sourceRoot . "/" . $sourcePath) ? hash_file('sha1', $sourceRoot . "/" . $sourcePath) : $sourcePath; hash_update($hash, $data); }
public function filterLoad(AssetInterface $asset) { $pb = $this->createProcessBuilder($this->nodeBin ? array($this->nodeBin, $this->tscBin) : array($this->tscBin)); if ($sourcePath = $asset->getSourcePath()) { $templateName = basename($sourcePath); } else { $templateName = 'asset'; } $inputDirPath = FilesystemUtils::createThrowAwayDirectory('typescript_in'); $inputPath = $inputDirPath . DIRECTORY_SEPARATOR . $templateName . '.ts'; $outputPath = FilesystemUtils::createTemporaryFile('typescript_out'); file_put_contents($inputPath, $asset->getContent()); $pb->add($inputPath)->add('--out')->add($outputPath); $proc = $pb->getProcess(); $code = $proc->run(); unlink($inputPath); rmdir($inputDirPath); if (0 !== $code) { if (file_exists($outputPath)) { unlink($outputPath); } throw FilterException::fromProcess($proc)->setInput($asset->getContent()); } if (!file_exists($outputPath)) { throw new \RuntimeException('Error creating output file.'); } $compiledJs = file_get_contents($outputPath); unlink($outputPath); $asset->setContent($compiledJs); }
public function filterLoad(AssetInterface $asset) { $pb = $this->createProcessBuilder($this->nodeBin ? array($this->nodeBin, $this->emberBin) : array($this->emberBin)); if ($sourcePath = $asset->getSourcePath()) { $templateName = basename($sourcePath); } else { throw new \LogicException('The embed-precompile filter requires that assets have a source path set'); } $inputDirPath = FilesystemUtils::createThrowAwayDirectory('ember_in'); $inputPath = $inputDirPath . DIRECTORY_SEPARATOR . $templateName; $outputPath = FilesystemUtils::createTemporaryFile('ember_out'); file_put_contents($inputPath, $asset->getContent()); $pb->add($inputPath)->add('-f')->add($outputPath); $process = $pb->getProcess(); $returnCode = $process->run(); unlink($inputPath); rmdir($inputDirPath); if (127 === $returnCode) { throw new \RuntimeException('Path to node executable could not be resolved.'); } if (0 !== $returnCode) { if (file_exists($outputPath)) { unlink($outputPath); } throw FilterException::fromProcess($process)->setInput($asset->getContent()); } if (!file_exists($outputPath)) { throw new \RuntimeException('Error creating output file.'); } $compiledJs = file_get_contents($outputPath); unlink($outputPath); $asset->setContent($compiledJs); }
/** * Performs the asset dump. * * @param AssetInterface $asset An asset * @param OutputInterface $stdout The command output * * @throws RuntimeException If there is a problem writing the asset */ private function doDump(AssetInterface $asset, OutputInterface $stdout) { $combinations = VarUtils::getCombinations($asset->getVars(), $this->getContainer()->getParameter('assetic.variables')); foreach ($combinations as $combination) { $asset->setValues($combination); // resolve the target path $target = rtrim($this->basePath, '/') . '/' . $asset->getTargetPath(); $target = str_replace('_controller/', '', $target); $target = VarUtils::resolve($target, $asset->getVars(), $asset->getValues()); if (!is_dir($dir = dirname($target))) { $stdout->writeln(sprintf('<comment>%s</comment> <info>[dir+]</info> %s', date('H:i:s'), $dir)); if (false === @mkdir($dir, 0777, true)) { throw new \RuntimeException('Unable to create directory ' . $dir); } } $stdout->writeln(sprintf('<comment>%s</comment> <info>[file+]</info> %s', date('H:i:s'), $target)); if (OutputInterface::VERBOSITY_VERBOSE <= $stdout->getVerbosity()) { if ($asset instanceof AssetCollectionInterface) { foreach ($asset as $leaf) { $root = $leaf->getSourceRoot(); $path = $leaf->getSourcePath(); $stdout->writeln(sprintf(' <comment>%s/%s</comment>', $root ?: '[unknown root]', $path ?: '[unknown path]')); } } else { $root = $asset->getSourceRoot(); $path = $asset->getSourcePath(); $stdout->writeln(sprintf(' <comment>%s/%s</comment>', $root ?: '[unknown root]', $path ?: '[unknown path]')); } } if (false === @file_put_contents($target, $asset->dump())) { throw new \RuntimeException('Unable to write file ' . $target); } } }
public function filterLoad(AssetInterface $asset) { $pb = $this->createProcessBuilder($this->nodeBin ? array($this->nodeBin, $this->emberBin) : array($this->emberBin)); $templateName = basename($asset->getSourcePath()); $inputDirPath = sys_get_temp_dir() . DIRECTORY_SEPARATOR . uniqid('input_dir'); $inputPath = $inputDirPath . DIRECTORY_SEPARATOR . $templateName; $outputPath = tempnam(sys_get_temp_dir(), 'output'); mkdir($inputDirPath); file_put_contents($inputPath, $asset->getContent()); $pb->add($inputPath)->add('-f')->add($outputPath); if ($this->includeBaseDir) { $pb->add('-b')->add($inputDirPath . DIRECTORY_SEPARATOR); } $process = $pb->getProcess(); $returnCode = $process->run(); unlink($inputPath); rmdir($inputDirPath); if (127 === $returnCode) { throw new \RuntimeException('Path to node executable could not be resolved.'); } if (0 !== $returnCode) { if (file_exists($outputPath)) { unlink($outputPath); } throw FilterException::fromProcess($process)->setInput($asset->getContent()); } if (!file_exists($outputPath)) { throw new \RuntimeException('Error creating output file.'); } $compiledJs = file_get_contents($outputPath); unlink($outputPath); $asset->setContent($compiledJs); }
/** * @param AssetInterface $asset */ public function filterDump(AssetInterface $asset) { $sourceBase = $asset->getSourceRoot(); $sourcePath = $asset->getSourcePath(); $assetRoot = $this->assetRoot; if (null === $sourcePath) { return; } $content = $this->filterReferences($asset->getContent(), function ($matches) use($sourceBase, $sourcePath, $assetRoot) { // its not a relative path if (false !== strpos($matches['url'], '://') || 0 === strpos($matches['url'], '//') || 0 === strpos($matches['url'], 'data:') || isset($matches['url'][0]) && '/' == $matches['url'][0]) { return $matches[0]; } $url = $matches['url']; if (false !== ($pos = strpos($url, '?'))) { $url = substr($url, 0, $pos); } $sourceAsset = dirname($sourceBase . '/' . $sourcePath) . '/' . $url; if (!is_file($sourceAsset)) { return $matches[0]; } $mimeType = MimeTypeGuesser::getInstance()->guess($sourceAsset); $destRelativePath = substr($mimeType, 0, strpos($mimeType, '/')) . '/' . basename($url); $destAsset = $assetRoot . '/' . $destRelativePath; if (!is_dir(dirname($destAsset))) { mkdir(dirname($destAsset), 0777, true); } copy($sourceAsset, $destAsset); return str_replace($matches['url'], '../' . $destRelativePath, $matches[0]); }); $asset->setContent($content); }
public function filterDump(AssetInterface $asset) { $content = $asset->getContent(); $config = array_merge(array('filename' => $asset->getSourcePath()), $this->config); $content = Compiler::compile($content, $config); $asset->setContent($content); }
public function filterLoad(AssetInterface $asset) { $pb = $this->createProcessBuilder($this->nodeBin ? array($this->nodeBin, $this->tscBin) : array($this->tscBin)); $templateName = basename($asset->getSourcePath()); $inputDirPath = sys_get_temp_dir() . DIRECTORY_SEPARATOR . uniqid('input_dir'); $inputPath = $inputDirPath . DIRECTORY_SEPARATOR . $templateName . '.ts'; $outputPath = tempnam(sys_get_temp_dir(), 'output'); mkdir($inputDirPath); file_put_contents($inputPath, $asset->getContent()); $pb->add($inputPath)->add('--out')->add($outputPath); $proc = $pb->getProcess(); $code = $proc->run(); unlink($inputPath); rmdir($inputDirPath); if (0 !== $code) { if (file_exists($outputPath)) { unlink($outputPath); } throw FilterException::fromProcess($proc)->setInput($asset->getContent()); } if (!file_exists($outputPath)) { throw new \RuntimeException('Error creating output file.'); } $compiledJs = file_get_contents($outputPath); unlink($outputPath); $asset->setContent($compiledJs); }
/** * Sets the by-config generated imports on the asset. * * {@inheritDoc} */ public function filterLoad(AssetInterface $asset) { $assetRoot = $asset->getSourceRoot(); $assetPath = $asset->getSourcePath(); $assetImportDir = dirname($assetRoot . '/' . $assetPath); $importDir = $this->config->getBootstrapPath() . '/less'; $this->setupLoadPaths($assetImportDir); // Make sure we _always_ have the bootstrap import dir. if ($importDir !== $assetImportDir) { $this->lessFilter->addLoadPath($importDir); } $variables = array_merge($this->extractVariables($importDir . '/variables.less'), $this->config->getVariables()); $variablesString = ''; foreach ($variables as $key => $value) { $variablesString .= "@{$key}:{$value};" . PHP_EOL; } if ('bootstrap.less' === $assetPath) { $imports = $this->filterImportFiles(array_unique(array_merge($this->extractImports($importDir . '/bootstrap.less'), $this->extractImports($importDir . '/responsive.less'), $this->config->getCustomComponents()))); $assetContent = $variablesString . $imports; $asset->setContent($assetContent); } else { $asset->setContent($variablesString . $asset->getContent()); } $this->lessFilter->filterLoad($asset); }
public function filterDump(AssetInterface $asset) { $content = ""; $files = array(); $extraFiles = array(); $absolutePath = $asset->getSourceRoot() . '/' . $asset->getSourcePath(); $this->parser->mime = $this->parser->mimeType($absolutePath); if ($this->parser->mime === 'javascripts') { $extraFiles = $this->parser->get("javascript_files", array()); } if ($this->parser->mime === 'stylesheets') { $extraFiles = $this->parser->get("stylesheet_files", array()); } $absoluteFilePaths = $this->parser->getFilesArrayFromDirectives($absolutePath); if ($absoluteFilePaths) { $absoluteFilePaths = $extraFiles + $absoluteFilePaths; } foreach ($absoluteFilePaths as $absoluteFilePath) { $files[] = $this->generator->file($absoluteFilePath, false); } if (!$absoluteFilePaths) { $files[] = $this->generator->file($absolutePath, false); } $global_filters = $this->parser->get("sprockets_filters.{$this->parser->mime}", array()); $collection = new AssetCollection($files, $global_filters); $asset->setContent($collection->dump()); }
public function filterLoad(AssetInterface $asset) { $parser = new Less_Parser(); // CSS Rewriter will take care of this $parser->SetOption('relativeUrls', false); $parser->parseFile($asset->getSourceRoot() . '/' . $asset->getSourcePath()); $asset->setContent($parser->getCss()); }
public function filterDump(AssetInterface $asset) { $this->root = $asset->getSourceRoot() . '/'; $this->file = $asset->getSourcePath(); $this->base = $this->getRelativePath($this->paths, $this->root); $content = $this->filterReferences($asset->getContent(), array($this, 'url_matcher')); $asset->setContent($content); }
public function filterLoad(AssetInterface $asset) { $importFilter = $this->importFilter; $sourceRoot = $asset->getSourceRoot(); $sourcePath = $asset->getSourcePath(); $callback = function ($matches) use($importFilter, $sourceRoot, $sourcePath) { if (!$matches['url']) { return $matches[0]; } if (null === $sourceRoot) { return $matches[0]; } $importRoot = $sourceRoot; if (false !== strpos($matches['url'], '://')) { // absolute list($importScheme, $tmp) = explode('://', $matches['url'], 2); list($importHost, $importPath) = explode('/', $tmp, 2); $importRoot = $importScheme . '://' . $importHost; } elseif (0 === strpos($matches['url'], '//')) { // protocol-relative list($importHost, $importPath) = explode('/', substr($matches['url'], 2), 2); $importHost = '//' . $importHost; } elseif ('/' == $matches['url'][0]) { // root-relative $importPath = substr($matches['url'], 1); } elseif (null !== $sourcePath) { // document-relative $importPath = $matches['url']; if ('.' != ($sourceDir = dirname($sourcePath))) { $importPath = $sourceDir . '/' . $importPath; } } else { return $matches[0]; } // ignore other imports if ('css' != pathinfo($importPath, PATHINFO_EXTENSION)) { return $matches[0]; } $importSource = $importRoot . '/' . $importPath; if (false !== strpos($importSource, '://') || 0 === strpos($importSource, '//')) { $import = new HttpAsset($importSource, array($importFilter), true); } elseif (!file_exists($importSource)) { // ignore not found imports return $matches[0]; } else { $import = new FileAsset($importSource, array($importFilter), $importRoot, $importPath); } $import->setTargetPath($sourcePath); return $import->dump(); }; $content = $asset->getContent(); $lastHash = md5($content); do { $content = $this->filterImports($content, $callback); $hash = md5($content); } while ($lastHash != $hash && ($lastHash = $hash)); $asset->setContent($content); }
public function filterDump(AssetInterface $asset) { $sourceBase = $asset->getSourceRoot(); $sourcePath = $asset->getSourcePath(); $targetPath = $asset->getTargetPath(); if (null === $sourcePath || null === $targetPath || $sourcePath == $targetPath) { return; } // learn how to get from the target back to the source if (false !== strpos($sourceBase, '://')) { list($scheme, $url) = explode('://', $sourceBase . '/' . $sourcePath, 2); list($host, $path) = explode('/', $url, 2); $host = $scheme . '://' . $host . '/'; $path = false === strpos($path, '/') ? '' : dirname($path); $path .= '/'; } else { // assume source and target are on the same host $host = ''; // pop entries off the target until it fits in the source if ('.' == dirname($sourcePath)) { $path = str_repeat('../', substr_count($targetPath, '/')); } elseif ('.' == ($targetDir = dirname($targetPath))) { $path = dirname($sourcePath) . '/'; } else { while (0 !== strpos($sourcePath, $targetDir)) { if (false !== ($pos = strrpos($targetDir, '/'))) { $targetDir = substr($targetDir, 0, $pos); } else { $targetDir = ''; break; } } $path = '/'; $path .= ltrim(substr(dirname($sourcePath) . '/', strlen($targetDir)), '/'); } } $content = $this->filterReferences($asset->getContent(), function ($matches) use($host, $path) { if (false !== strpos($matches['url'], '://') || 0 === strpos($matches['url'], '//') || 0 === strpos($matches['url'], 'data:')) { // absolute or protocol-relative or data uri return $matches[0]; } if ('/' == $matches['url'][0]) { // root relative return str_replace($matches['url'], $host . $matches['url'], $matches[0]); } // document relative $url = $matches['url']; $parts = array(); foreach (explode('/', $host . $path . $url) as $part) { if ('..' === $part && count($parts) && '..' !== end($parts)) { array_pop($parts); } $parts[] = $part; } return str_replace($matches['url'], implode('/', $parts), $matches[0]); }); $asset->setContent($content); }
public function filterLoad(AssetInterface $asset) { $namespace = $this->namespace; $ext = $this->ext; $template_name = str_replace($ext, '', $asset->getSourcePath()); $template_contents = addslashes(preg_replace("/[\n\r\t ]+/", " ", $asset->getContent())); $content = "{$namespace}['{$template_name}'] = _.template(" . "'{$template_contents}');" . PHP_EOL; $asset->setContent($content); }
/** * {@inheritdoc} */ public function getSourcePath() { if ($this->innerAsset) { return $this->innerAsset->getSourcePath(); } // Not 100% accurate, but this method is called by // AssetCollectionIterator before setValues() is called, so we need // to return something return $this->input; }
public function filterLoad(AssetInterface $asset) { $root = $asset->getSourceRoot(); $path = $asset->getSourcePath(); $pce = new CssEmbed(); if ($root && $path) { $pce->setRootDir(dirname($root . '/' . $path)); } $asset->setContent($pce->embedString($asset->getContent())); }
public function filterLoad(AssetInterface $asset) { $root = $asset->getSourceRoot(); $path = $asset->getSourcePath(); $lc = new \lessc(); if ($root && $path) { $lc->importDir = dirname($root . '/' . $path); } $asset->setContent($lc->parse($asset->getContent())); }
public function filterLoad(AssetInterface $asset) { $content = $asset->getContent(); $root = $asset->getSourceRoot(); $path = $asset->getSourcePath(); if (!empty($content)) { $content = \CoffeeScript\Compiler::compile($asset->getContent(), array('filename' => $path)); } $asset->setContent($content); }
public function filterLoad(AssetInterface $asset) { $root = $asset->getSourceRoot(); $path = $asset->getSourcePath(); $lc = new \scssc(); if ($root && $path) { $lc->addImportPath(dirname($root . '/' . $path)); } $asset->setContent($lc->compile($asset->getContent())); }