titanscssc::compile PHP Method

compile() public method

public compile ( $code, $name = null )
    public function compile($code, $name = null)
    {
        $this->indentLevel = -1;
        $this->commentsSeen = array();
        $this->extends = array();
        $this->extendsMap = array();
        $locale = setlocale(LC_NUMERIC, 0);
        setlocale(LC_NUMERIC, "C");
        $this->parsedFiles = array();
        $this->parser = new titanscss_parser($name);
        $tree = $this->parser->parse($code);
        $this->formatter = new $this->formatter();
        $this->env = null;
        $this->scope = null;
        $this->compileRoot($tree);
        $out = $this->formatter->format($this->scope);
        setlocale(LC_NUMERIC, $locale);
        return $out;
    }

Usage Example

 /**
  * Prints CSS styles in the header for meta options using wp_print_scripts
  *
  * @return	void
  * @since	1.3
  */
 public function printCSSForPagesAndPosts()
 {
     // This is for meta box options only, other types get generated normally
     if (TitanFrameworkOption::TYPE_META != $this->type) {
         return;
     }
     // For CSS langs only
     if ($this->settings['lang'] != 'css') {
         return;
     }
     // Don't generate CSS for non-pages and non-posts
     $id = get_the_ID();
     if (empty($id) || 1 == $id) {
         return;
     }
     // Check if a CSS was entered
     $css = $this->getFramework()->getOption($this->settings['id'], $id);
     if (empty($css)) {
         return;
     }
     // Print out valid CSS only
     require_once trailingslashit(dirname(dirname(__FILE__))) . 'inc/scssphp/scss.inc.php';
     $scss = new titanscssc();
     try {
         $css = $scss->compile($css);
         echo "<style type='text/css' media='screen'>{$css}</style>";
     } catch (Exception $e) {
     }
 }
All Usage Examples Of titanscssc::compile
titanscssc