/** * Converts the ruleset to CSS * * @param ILess_Node_Ruleset $ruleset * @param array $variables * @return string The generated CSS code */ protected function toCSS(ILess_Node_Ruleset $ruleset, array $variables) { $this->setupMathAndLocale(); $this->prepareVariables($this->env, $variables); // precompilation visitors foreach ($this->getPreCompileVisitors() as $visitor) { $visitor->run($ruleset); } // compile the ruleset $compiled = $ruleset->compile($this->env); // post compilation visitors foreach ($this->getPostCompileVisitors() as $visitor) { $visitor->run($compiled); } if ($this->getEnvironment()->sourceMap) { $generator = new ILess_SourceMap_Generator($compiled, $this->env->getContentsMap(), $this->env->sourceMapOptions); // will also save file // FIXME: should happen somewhere else? $css = $generator->generateCSS($this->env); } else { $css = $compiled->toCSS($this->env); } if ($this->env->compress) { $css = preg_replace('/(^(\\s)+)|((\\s)+$)/', '', $css); } $this->restoreMathAndLocale(); return $css; }