forked from nizsheanez/yii2-asset-converter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSass.php
35 lines (28 loc) · 842 Bytes
/
Sass.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
<?php
namespace nizsheanez\assetConverter;
use Yii;
class Sass extends Parser
{
/**
* @var string to the class pointing to where sass parser is located.
*/
public $sassParserClass = '\SassParser';
/**
* @var string to the sass parser cache
*/
public $cachePath = '@app/runtime/cache/sass-parser';
/**
* Parse a Sass file to CSS
*/
public function parse($src, $dst, $options)
{
if (!empty($options['cachePath'])) {
$options['cache_location'] = Yii::getAlias($options['cachePath']);
if (!is_dir($options['cache_location'])) {
mkdir($options['cache_location'], 0777, true);
}
}
$parser = Yii::createObject($this->sassParserClass, $options);
file_put_contents($dst, $parser->toCss($src));
}
}