/** * Build the parameters for the sass compiler * * @return array Array of parameters */ protected function getParameters() { $params = array(); // format if (strtolower(sfConfig::get('app_sfSassyCssPlugin_format')) == 'scss') { $params[] = '--scss'; } // cache if (sfConfig::get('app_sfSassyCssPlugin_cache')) { $params[] = sprintf('--cache-location "%s"', sfSassCompilerDriver::fixPath(sfConfig::get('app_sfSassyCssPlugin_cache_dir'))); } else { $params[] = '--no-cache'; } // output style $params[] = sprintf('--style %s', sfConfig::get('app_sfSassyCssPlugin_style')); // encoding if (sfConfig::get('app_sfSassyCssPlugin_encoding') !== null) { $params[] = sprintf('-E "%s"', sfConfig::get('app_sfSassyCssPlugin_encoding')); } // debug if (sfConfig::get('app_sfSassyCssPlugin_trace')) { $params[] = '--trace'; } if (sfConfig::get('app_sfSassyCssPlugin_debug_info')) { $params[] = '--debug-info'; } if (sfConfig::get('app_sfSassyCssPlugin_line_numbers')) { $params[] = '--line-numbers'; } if (sfConfig::get('app_sfSassyCssPlugin_line_comments')) { $params[] = '--line-comments'; } // include path foreach (sfConfig::get('app_sfSassyCssPlugin_include_dirs') as $path) { $params[] = sprintf('--load-path "%s"', sfSassCompilerDriver::fixPath($path)); } return $params; }
/** * @see sfTask */ protected function execute($arguments = array(), $options = array()) { $compiler = sfSassCompilerArgs::getInstance($this->dispatcher); $in = sfConfig::get('app_sfSassyCssPlugin_input_dir', sfConfig::get('sf_data_dir') . '/sass'); $out = sfConfig::get('app_sfSassyCssPlugin_output_dir', sfConfig::get('sf_web_dir') . '/css'); $params = array(); // Clean if (!$options['no-clean']) { $this->logSection('Clean', 'remove previously generated css files'); $compiler->clean($in, $out); } $params[] = '--no-cache'; if (sfConfig::get('app_sfSassyCssPlugin_encoding') !== null) { $params[] = sprintf('-E "%s"', sfConfig::get('app_sfSassyCssPlugin_encoding')); } if ($options['format'] == 'scss') { $params[] = sprintf('--scss'); } if ($options['debug']) { $params[] = '--debug-info'; $params[] = '--line-numbers'; $params[] = '--line-comments'; $params[] = '--style expanded'; } else { $params[] = sprintf('--style %s', $options['style']); } foreach (sfConfig::get('app_sfSassyCssPlugin_include_dirs') as $path) { $params[] = sprintf('--load-path "%s"', sfSassCompilerDriver::fixPath($path)); } $compiler->compile($in, $out, null, $params); $this->logSection('Command', $compiler->getCommand()); $stdout = $compiler->getStdOut(); $status = $compiler->getStatus(); if (!empty($stdout)) { $this->logBlock("\n" . $stdout . "\n", preg_match('/error /i', $stdout) !== 0 ? 'ERROR' : 'INFO'); } $this->logSection('Status', $status); }