From 100e9c8a0f066af6ae1e0a753e3d9400ecbe732a Mon Sep 17 00:00:00 2001 From: Anthon Pang Date: Sat, 16 Mar 2013 22:27:55 -0400 Subject: [PATCH] a parser will parse(), a compiler will compile(), so too a formatter shall format() --- scss.inc.php | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/scss.inc.php b/scss.inc.php index a94dc2e4..57a77cdc 100644 --- a/scss.inc.php +++ b/scss.inc.php @@ -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; @@ -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(); @@ -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; + } } /** @@ -3930,7 +3936,7 @@ public function adjustAllChildren($block) { } } - public function block($block) { + protected function block($block) { if ($block->type == "root") { $this->adjustAllChildren($block); }