Leafo\ScssPhp\Compiler::compile PHP Method

compile() public method

Compile scss
public compile ( string $code, string $path = null ) : string
$code string
$path string
return string
    public function compile($code, $path = null)
    {
        $locale = setlocale(LC_NUMERIC, 0);
        setlocale(LC_NUMERIC, 'C');
        $this->indentLevel = -1;
        $this->commentsSeen = [];
        $this->extends = [];
        $this->extendsMap = [];
        $this->sourceIndex = null;
        $this->sourceLine = null;
        $this->sourceColumn = null;
        $this->env = null;
        $this->scope = null;
        $this->storeEnv = null;
        $this->charsetSeen = null;
        $this->shouldEvaluate = null;
        $this->stderr = fopen('php://stderr', 'w');
        $this->parser = $this->parserFactory($path);
        $tree = $this->parser->parse($code);
        $this->parser = null;
        $this->formatter = new $this->formatter();
        $this->rootBlock = null;
        $this->rootEnv = $this->pushEnv($tree);
        $this->injectVariables($this->registeredVars);
        $this->compileRoot($tree);
        $this->popEnv();
        $out = $this->formatter->format($this->scope);
        setlocale(LC_NUMERIC, $locale);
        return $out;
    }

Usage Example

Example #1
0
 public function compile(Filesystem $files, $source, $dest)
 {
     $scss = $files->get($source);
     $this->compiler->setImportPaths(array_merge([$this->getPath($source)], $this->importPaths));
     $css = $this->compiler->compile($scss);
     $files->put($dest, $css);
 }
All Usage Examples Of Leafo\ScssPhp\Compiler::compile
Compiler