/** * Compiles the $uncompiledFile into CSS */ public function compile() { if (MetaLanguages::within_modification_tolerance($this->uncompiledFile, $this->getCompiledPath())) { return; } $path = $this->getCompiledPath(); if (file_exists($path) && !is_writable($this->getCompiledPath())) { user_error("SCSS compiling error: {$path} is not writable.", E_USER_ERROR); } elseif (!is_writable(dirname($path))) { user_error("SCSS compiling error: {$path} is not writable.", E_USER_ERROR); } lessc::ccompile(BASE_PATH . "/" . $this->uncompiledFile, BASE_PATH . "/" . $path); }
/** * Compiles the $uncompiledFile into CSS */ public function compile() { if (MetaLanguages::within_modification_tolerance($this->uncompiledFile, $this->getCompiledPath())) { return; } $path = $this->getCompiledPath(); $parser = new SassParser(); $sass = $parser->toCss(BASE_PATH . "/" . $this->uncompiledFile); if (file_exists($path) && !is_writable($this->getCompiledPath())) { user_error("SCSS compiling error: {$path} is not writable.", E_USER_ERROR); } elseif (!is_writable(BASE_PATH . "/" . $path)) { user_error("SCSS compiling error: {$path} is not writable.", E_USER_ERROR); } $file = fopen(BASE_PATH . "/" . $path, "w"); fwrite($file, $sass); fclose($file); }
/** * Compiles the $uncompiledFile into JS */ public function compile() { if (!class_exists("CoffeeScript\\Compiler")) { user_error("CoffeeScript requires the PHP CoffeeScript compiler to run. You can install with \"composer require coffeescript/coffeescript\"", E_USER_ERROR); } if (MetaLanguages::within_modification_tolerance($this->uncompiledFile, $this->getCompiledPath())) { return; } $file = BASE_PATH . '/' . $this->uncompiledFile; try { $coffee = file_get_contents($file); $js = CoffeeScript\Compiler::compile($coffee, array('filename' => $file)); $js_file = fopen(BASE_PATH . '/' . $this->getCompiledPath(), "w"); fwrite($js_file, $js); fclose($js_file); } catch (Exception $e) { user_error($e->getMessage(), E_USER_ERROR); } }