Beispiel #1
0
 /**
  * Handle $data, and return the results.
  *
  * @param string data The data to handle.
  * @return string
  * @access public
  */
 public function input($data, $options = array())
 {
     $default_options = array('minify' => true);
     $result = null;
     $options = array_merge($default_options, $options);
     try {
         if (strpos($data, NL) === false && is_file($data)) {
             $data = file_get_contents($data);
             if ($data === false) {
                 throw new \Exception('Could not load CSS: ' . $data);
             }
         }
         require_once CURATOR_APP_DIR . DS . 'Vendors' . DS . 'css-compressor' . DS . 'dist' . DS . 'src' . DS . 'CSSCompression.php';
         $result = \CSSCompression::express($data, 'sane');
     } catch (\Exception $e) {
         \Curator\Console::stderr('** Could not handle CSS data:');
         \Curator\Console::stderr('  ' . $e->getMessage());
     }
     return $result;
 }
Beispiel #2
0
 /**
  * Static access for direct compression
  *
  * @param (string) css: Stylesheet to be compressed
  * @param (mixed) options: Array of options or mode to use.
  */
 public static function express($css = NULL, $options = NULL)
 {
     if (!self::$express) {
         self::$express = new CSSCompression();
     }
     self::$express->reset();
     return self::$express->compress($css, $options);
 }