Skip to content

Commit

Permalink
a parser will parse(), a compiler will compile(), so too a formatter …
Browse files Browse the repository at this point in the history
…shall format()
  • Loading branch information
robocoder committed Mar 17, 2013
1 parent c229c20 commit 100e9c8
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions scss.inc.php
Expand Up @@ -85,9 +85,7 @@ function compile($code, $name=null) {

$this->compileRoot($tree);

ob_start();
$this->formatter->block($this->scope);
$out = ob_get_clean();
$out = $this->formatter->format($this->scope);

setlocale(LC_NUMERIC, $locale);
return $out;
Expand Down Expand Up @@ -3852,7 +3850,7 @@ public function property($name, $value) {
return $name . $this->assignSeparator . $value . ";";
}

public function block($block) {
protected function block($block) {
if (empty($block->lines) && empty($block->children)) return;

$inner = $pre = $this->indentStr();
Expand Down Expand Up @@ -3883,6 +3881,14 @@ public function block($block) {
echo $pre . $this->close . $this->break;
}
}

public function format($block) {
ob_start();
$this->block($block);
$out = ob_get_clean();

return $out;
}
}

/**
Expand Down Expand Up @@ -3930,7 +3936,7 @@ public function adjustAllChildren($block) {
}
}

public function block($block) {
protected function block($block) {
if ($block->type == "root") {
$this->adjustAllChildren($block);
}
Expand Down

0 comments on commit 100e9c8

Please sign in to comment.