예제 #1
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;
 }
예제 #2
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;
 }
예제 #3
0
 private static function _init_coffeescript()
 {
     if (!self::$freeze and !self::$_coffeescript_loaded) {
         // Start benchmark
         if (self::$_enable_benchmark) {
             self::$_ci->benchmark->mark("Assets::init_coffeescript()_start");
         }
         // Load classes
         if (defined('SPARKPATH')) {
             include reduce_double_slashes(SPARKPATH . 'assets/' . ASSETS_VERSION . '/libraries/coffeescript/Init.php');
         } else {
             include reduce_double_slashes(APPPATH . '/third_party/assets/coffeescript/coffeescript.php');
         }
         // Initialize
         CoffeeScript\Init::load();
         self::$_coffeescript_loaded = true;
         // End benchmark
         if (self::$_enable_benchmark) {
             self::$_ci->benchmark->mark("Assets::init_coffeescript()_end");
         }
     }
 }
예제 #4
0
파일: index.php 프로젝트: yashb/generator
/**
 * Quick and dirty test driver for CoffeeScript PHP.
 *
 * For each test we check two things, the tokens produced by the lexer/rewriter,
 * and the compiled JavaScript, by comparing them against references produced
 * by the original compiler.
 */
ini_set('display_errors', '1');
error_reporting(E_ALL);
// Test case to run
$case = isset($_GET['case']) ? $_GET['case'] : FALSE;
if ($case) {
    $PHP = array('coffee' => file_get_contents($case), 'error' => NULL, 'js' => NULL, 'rewrite' => !(isset($_GET['rewrite']) && $_GET['rewrite'] === 'off'), 'tokens' => array());
    require '../src/CoffeeScript/Init.php';
    CoffeeScript\Init::load();
    $options = array('filename' => $case, 'header' => FALSE, 'rewrite' => $PHP['rewrite'], 'tokens' => &$PHP['tokens']);
    try {
        $PHP['js'] = CoffeeScript\Compiler::compile($PHP['coffee'], $options);
    } catch (Exception $e) {
        $PHP['error'] = $e->getMessage();
    }
    if ($PHP['tokens']) {
        // Change the tokens to their canonical form so we can compare them against
        // those produced by the reference.
        $PHP['tokens'] = CoffeeScript\Lexer::t_canonical($PHP['tokens']);
    }
}
?>
<!doctype html>
<html>