public function testNoHeader() { $asset = new StringAsset('square = (x) -> x * x'); $asset->load(); $this->filter->setNoHeader(true); $this->filter->filterLoad($asset); $this->assertNotRegExp('/^\\/\\/ Generated by CoffeeScript/i', $asset->getContent()); }
public function testFilterLoad() { if (!isset($_SERVER['COFFEE_BIN']) || !isset($_SERVER['NODE_BIN'])) { $this->markTestSkipped('There is no COFFEE_BIN or NODE_BIN environment variable.'); } $expected = <<<JAVASCRIPT (function() { var square; square = function(x) { return x * x; }; }).call(this); JAVASCRIPT; $asset = new StringAsset('square = (x) -> x * x'); $asset->load(); $filter = new CoffeeScriptFilter($_SERVER['COFFEE_BIN'], $_SERVER['NODE_BIN']); $filter->filterLoad($asset); $this->assertEquals($expected, $asset->getContent()); }
/** * Bootstraps the application. * * This method is called after all services are registered * and should be used for "dynamic" configuration (whenever * a service must be requested). * * @param Application $app * @throws \InvalidArgumentException */ public function boot(Application $app) { $app['assetic.filters'] = $app->share($app->extend('assetic.filters', function ($filters) use($app) { $filters['coffee'] = $app->share(function () use($app) { $filter = new CoffeeScriptFilter($app['assetic.filter.coffee.bin'], $app['assetic.filter.coffee.node']); $filter->setTimeout($app['assetic.filter.coffee.timeout']); $filter->setNodePaths($app['assetic.filter.coffee.node_paths']); $filter->setBare($app['assetic.filter.coffee.bare']); $filter->setNoHeader($app['assetic.filter.coffee.no_header']); return $filter; }); return $filters; })); }