Beans_Lessc::compile PHP Метод

compile() публичный Метод

public compile ( $string, $name = null )
    public function compile($string, $name = null)
    {
        $locale = setlocale(LC_NUMERIC, 0);
        setlocale(LC_NUMERIC, "C");
        $this->parser = $this->makeParser($name);
        $root = $this->parser->parse($string);
        $this->env = null;
        $this->scope = null;
        $this->formatter = $this->newFormatter();
        if (!empty($this->registeredVars)) {
            $this->injectVariables($this->registeredVars);
        }
        $this->sourceParser = $this->parser;
        // used for error messages
        $this->compileBlock($root);
        ob_start();
        $this->formatter->block($this->scope);
        $out = ob_get_clean();
        setlocale(LC_NUMERIC, $locale);
        return $out;
    }

Usage Example

Пример #1
0
 /**
  * Formal CSS, LESS and JS content.
  */
 public function format_content($content)
 {
     if ('style' == $this->compiler['type']) {
         if ('less' == $this->compiler['format']) {
             if (!class_exists('Beans_Lessc')) {
                 require_once BEANS_API_PATH . 'compiler/vendors/lessc.php';
             }
             $less = new Beans_Lessc();
             $content = $less->compile($content);
         }
         if (!_beans_is_compiler_dev_mode()) {
             $content = $this->strip_whitespace($content);
         }
     }
     if ('script' == $this->compiler['type'] && !_beans_is_compiler_dev_mode() && $this->compiler['minify_js']) {
         if (!class_exists('JSMin')) {
             require_once BEANS_API_PATH . 'compiler/vendors/js-minifier.php';
         }
         $js_min = new JSMin($content);
         $content = $js_min->min();
     }
     return $content;
 }