Beispiel #1
0
 /**
  * Process asset content
  *
  * @param   string $content
  * @param   Asset  $asset
  *
  * @return  string
  */
 public static function process($content, Asset $asset)
 {
     // Set Less
     $lc = new lessc();
     $lc->importDir = dirname($asset->source_file()) . DIRECTORY_SEPARATOR;
     return $lc->parse($content);
 }
Beispiel #2
0
 public function test_process()
 {
     $asset = new Asset(Assets::STYLESHEET, 'test-sass.css.sass');
     $sass = file_get_contents($asset->source_file());
     $css = file_get_contents($asset->destination_file());
     $converted = Asset_Engine_Sass::process($sass, $asset);
     $this->assertEquals($css, $converted);
 }
Beispiel #3
0
 public function test_process()
 {
     $asset = new Asset(Assets::JAVASCRIPT, 'test-coffee.js.coffee');
     $coffee = file_get_contents($asset->source_file());
     $js = file_get_contents($asset->destination_file());
     $converted = Asset_Engine_Coffee::process($coffee, $asset);
     $this->assertEquals($js, $converted);
 }
Beispiel #4
0
 /**
  * Process asset content
  *
  * @param   string $content
  * @param   Asset  $asset
  *
  * @return  string
  */
 public static function process($content, Asset $asset)
 {
     // Set error reporting
     $old = error_reporting(E_ALL & ~(E_NOTICE | E_DEPRECATED | E_STRICT));
     // Set content
     CoffeeScript\Init::load();
     $options = array('filename' => Debug::path($asset->source_file()), 'header' => FALSE);
     $content = CoffeeScript\Compiler::compile($content, $options);
     // Set error reporting
     error_reporting($old);
     return $content;
 }
Beispiel #5
0
 /**
  * Process asset content
  *
  * @param   string  $content
  * @param   Asset   $asset
  * @return  string
  */
 public static function process($content, Asset $asset)
 {
     // Set error reporting
     $old = error_reporting(E_ALL & ~(E_NOTICE | E_DEPRECATED | E_STRICT));
     // Include the engine
     include_once Kohana::find_file('vendor/coffeescript/CoffeeScript', 'Init');
     // Set content
     CoffeeScript\Init::load();
     $options = array('filename' => Debug::path($asset->source_file()), 'header' => TRUE);
     $content = CoffeeScript\Compiler::compile($content, $options);
     // Set error reporting
     error_reporting($old);
     return $content;
 }
Beispiel #6
0
 public function test_construct()
 {
     $asset = new Asset(Assets::JAVASCRIPT, 'test.js');
     $this->assertEquals(self::data_dir() . 'js' . DIRECTORY_SEPARATOR . 'test.js', $asset->source_file());
     $this->assertEquals(self::data_dir() . 'assets' . DIRECTORY_SEPARATOR . 'js' . DIRECTORY_SEPARATOR . 'test.js', $asset->destination_file());
     $this->assertEquals('assets/js/test.js', $asset->destination_web());
     $this->assertEquals(array(), $asset->engines());
     $this->assertEquals(Assets::JAVASCRIPT, $asset->type());
     $asset = new Asset(Assets::JAVASCRIPT, 'test.js.coffee.php');
     $this->assertEquals(array('php', 'coffee'), $asset->engines());
     $asset = new Asset(Assets::JAVASCRIPT, 'test.js', array('condition' => 'IF ie', 'processor' => 'jsmin'));
     $this->assertEquals($asset->condition(), 'IF ie');
     $this->assertEquals($asset->processor(), 'jsmin');
 }