SassParser::toCss PHP Method

toCss() public method

Parse a sass file or Sass source code and returns the CSS.
public toCss ( string $source, boolean $isFile = true ) : string
$source string name of source file or Sass source
$isFile boolean
return string CSS
    public function toCss($source, $isFile = true)
    {
        return $this->parse($source, $isFile)->render();
    }

Usage Example

Example #1
0
 private function _compile_stylesheet($file)
 {
     PerchUtil::debug('Compiling SASS file: ' . $file, 'notice');
     if (!$this->_site_path) {
         $login_path_parts = explode('/', PERCH_LOGINPATH);
         $path_parts = explode(DIRECTORY_SEPARATOR, PERCH_PATH);
         foreach ($login_path_parts as $part) {
             if ($part != '') {
                 array_pop($path_parts);
             }
         }
         $path = implode(DIRECTORY_SEPARATOR, $path_parts);
         $this->_site_path = $path;
     }
     $compiled_name = PerchUtil::file_path(PERCH_RESFILEPATH . '/' . $this->_get_compiled_name($file));
     include_once 'SassParser.php';
     $syntax = substr($file, -4, 4);
     $options = array('style' => 'expanded', 'cache' => FALSE, 'syntax' => $syntax, 'debug' => FALSE, 'callbacks' => array('warn' => 'warn', 'debug' => 'debug'));
     // Execute the compiler.
     $parser = new SassParser($options);
     try {
         file_put_contents($compiled_name, $parser->toCss(PerchUtil::file_path($this->_site_path . $file)));
     } catch (Exception $e) {
         PerchUtil::debug($e->getMessage(), 'error');
     }
 }
All Usage Examples Of SassParser::toCss