/** * Filters an asset after it has been loaded. * * @param AssetInterface $asset */ public function filterLoad(AssetInterface $asset) { $asset->setContent($this->parser->parse($asset->getContent())); parent::filterLoad($asset); }
/** * @dataProvider provideImports */ public function testGetChildren($import) { $children = $this->filter->getChildren(new AssetFactory('/'), $import, __DIR__ . '/fixtures/less'); $this->assertCount(1, $children); $this->assertEquals('main.less', $children[0]->getSourcePath()); }
public function createLessFilter(CreateFilterEvent $event) { // filter is already created if ($event->getFilter()) { return; } $configuration = $event->getConfiguration(); // skip other filter types if ($configuration['type'] != 'less') { return; } if ($configuration['nodePath']) { $filter = new LessFilter($configuration['nodePath']); } else { $filter = new LessFilter(); } $paths = deserialize($configuration['nodePaths']); if (is_array($paths) && count($paths)) { $temp = array(); foreach ($paths as $path) { $temp[] = $path['path']; } $filter->setNodePaths($temp); } $event->setFilter($filter); }
protected function _setup_filters() { $config = $this->_get_config(); // Stylesheet filters $less = new LessFilter($config['node_path'], $config['node_paths']); $styl = new StylusFilter($config['node_path'], $config['node_paths']); // Enable compression if ($this->_is_debug() === false) { $less->setCompress(true); $styl->setCompress(true); } $this->_add_filter('less', $less); $this->_add_filter('styl', $styl); $css_embed = new CssEmbedFilter($config['cssembed_path']); if ($config['cssembed_root'] !== false) { $css_embed->setRoot($config['cssembed_root']); } $css_embed->setMhtml(false); $css_embed->setCharset('utf8'); $this->_add_filter('css_embed', $css_embed); $css_rewrite = new MyCssRewriteFilter($config['css_rewrite_replacement'], $config['css_rewrite_pattern']); $this->_add_filter('css_rewrite', $css_rewrite); // Javascript filters $this->_add_filter('yui_js', new Yui\JsCompressorFilter($config['yuicompressor_path'])); $this->_add_filter('coffee', new CoffeeScriptFilter($config['coffee_path'], $config['node_path'])); // Javascript template filters $this->_add_filter('handlebars', new HandlebarsFilter($config['handlebars_path'], $config['node_path'])); $this->_add_filter('underscore', new UnderscoreFilter($config['underscore_namespace']), $config['underscore_ext']); }