Skip to content

Commit acc5d87

Browse files
committed
Add "compact" formatter (for completeness)
1 parent a80542c commit acc5d87

File tree

3 files changed

+42
-2
lines changed

3 files changed

+42
-2
lines changed

bin/pscss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Options include:
3333
3434
-h, --help Show this message
3535
-v, --version Print the version
36-
-f=format Set the output format (compressed, crunched, expanded, or nested)
36+
-f=format Set the output format (compact, compressed, crunched, expanded, or nested)
3737
-T Dump formatted parse tree
3838
3939
EOT;
@@ -61,7 +61,7 @@ if (has("T")) {
6161
$scss = new Compiler();
6262

6363
if (has("f")) {
64-
$scss->setFormatter('Leafo\\ScssPhp\\' . ucfirst($opts["f"]));
64+
$scss->setFormatter('Leafo\\ScssPhp\\Formatter\\' . ucfirst($opts["f"]));
6565
}
6666

6767
echo $scss->compile($data, "STDIN");

scss.inc.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
include_once __DIR__ . '/src/Colors.php';
33
include_once __DIR__ . '/src/Compiler.php';
44
include_once __DIR__ . '/src/Formatter.php';
5+
include_once __DIR__ . '/src/Formatter/Compact.php';
56
include_once __DIR__ . '/src/Formatter/Compressed.php';
67
include_once __DIR__ . '/src/Formatter/Crunched.php';
78
include_once __DIR__ . '/src/Formatter/Expanded.php';

src/Formatter/Compact.php

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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 compact formatter
19+
*
20+
* @author Leaf Corcoran <leafot@gmail.com>
21+
*/
22+
class Compact extends Formatter
23+
{
24+
public function __construct()
25+
{
26+
$this->indentLevel = 0;
27+
$this->indentChar = '';
28+
$this->break = '';
29+
$this->open = ' {';
30+
$this->close = "}\n\n";
31+
$this->tagSeparator = ',';
32+
$this->assignSeparator = ':';
33+
}
34+
35+
public function indentStr($n = 0)
36+
{
37+
return ' ';
38+
}
39+
}

0 commit comments

Comments
 (0)