forked from leafo/scssphp-compass
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcompass.inc.php
41 lines (33 loc) · 925 Bytes
/
compass.inc.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
class scss_compass {
protected $libFunctions = array("lib_compact");
static public $true = array("keyword", "true");
static public $false = array("keyword", "false");
public function __construct($scss) {
$this->scss = $scss;
$this->updateImportPath();
$this->registerFunctions();
}
protected function updateImportPath() {
$this->scss->addImportPath(__DIR__ . "/stylesheets/");
}
protected function registerFunctions() {
foreach ($this->libFunctions as $fn) {
$registerName = $fn;
if (preg_match('/^lib_(.*)$/', $fn, $m)) {
$registerName = $m[1];
}
$this->scss->registerFunction($registerName, array($this, $fn));
}
}
public function lib_compact($args) {
list($list) = $args;
if ($list[0] != "list") return $list;
$filtered = array();
foreach ($list[2] as $item) {
if ($item != self::$false) $filtered[] = $item;
}
$list[2] = $filtered;
return $list;
}
}