public function text($indentStyle = ' ', $newLine = "\n", $level = 0)
{
$indent = str_repeat($indentStyle, $level);
$texts = [];
foreach ($this->children as $child) {
if ($child->type === 'text') {
$texts[] = $indent . $child->value;
$texts[] = $child->text($indentStyle, $newLine, $level + 1);
}
}
return implode($newLine, $texts);
}
/** * Compiles the SASS content to CSS * * @param Node $node the node to be compiled * @param string $indent the indentation to use on each child * @param string $newLine the new-line to append after each line * * @return string the wrapped SASS-CSS-string * @throws Compiler\Exception when the Stylus package is not installed */ public static function filterSass(Node $node, $indent, $newLine) { if (!class_exists('Leafo\\ScssPhp\\Compiler')) { throw new Compiler\Exception("Failed to compile SASS: " . "Please install the leafo/scssphp composer package"); } $sass = new \Leafo\ScssPhp\Compiler(); $css = $sass->compile($node->text()); return '<style>' . $newLine . $indent . $css . $newLine . $indent . '</style>'; }