| 1 |
<?php |
| 2 |
/** |
| 3 |
* SCSSPHP |
| 4 |
* |
| 5 |
* @copyright 2012-2014 Leaf Corcoran |
| 6 |
* |
| 7 |
* @license http://opensource.org/licenses/gpl-license GPL-3.0 |
| 8 |
* @license http://opensource.org/licenses/MIT MIT |
| 9 |
* |
| 10 |
* @link http://leafo.net/scssphp |
| 11 |
*/ |
| 12 |
|
| 13 |
namespace Leafo\ScssPhp\Formatter; |
| 14 |
|
| 15 |
use Leafo\ScssPhp\Formatter; |
| 16 |
|
| 17 |
/** |
| 18 |
* SCSS compressed formatter |
| 19 |
* |
| 20 |
* @author Leaf Corcoran <leafot@gmail.com> |
| 21 |
*/ |
| 22 |
class Compressed extends Formatter |
| 23 |
{ |
| 24 |
public function __construct() |
| 25 |
{ |
| 26 |
$this->indentLevel = 0; |
| 27 |
$this->indentChar = ' '; |
| 28 |
$this->break = ''; |
| 29 |
$this->open = '{'; |
| 30 |
$this->close = '}'; |
| 31 |
$this->tagSeparator = ','; |
| 32 |
$this->assignSeparator = ':'; |
| 33 |
} |
| 34 |
|
| 35 |
public function indentStr($n = 0) |
| 36 |
{ |
| 37 |
return ''; |
| 38 |
} |
| 39 |
|
| 40 |
public function blockLines($inner, $block) |
| 41 |
{ |
| 42 |
$glue = $this->break.$inner; |
| 43 |
|
| 44 |
foreach ($block->lines as $index => $line) { |
| 45 |
if (substr($line, 0, 2) === '/*' && substr($line, 2, 1) !== '!') { |
| 46 |
unset($block->lines[$index]); |
| 47 |
} elseif (substr($line, 0, 3) === '/*!') { |
| 48 |
$block->lines[$index] = '/*' . substr($line, 3); |
| 49 |
} |
| 50 |
} |
| 51 |
|
| 52 |
echo $inner . implode($glue, $block->lines); |
| 53 |
|
| 54 |
if (!empty($block->children)) { |
| 55 |
echo $this->break; |
| 56 |
} |
| 57 |
} |
| 58 |
} |
| 59 |
|