source: branches/2.5/prototype/library/Assetic/Filter/ScssphpFilter.php @ 7575

Revision 7575, 1.6 KB checked in by angelo, 12 years ago (diff)

Ticket #3197 - Reduzir tempo de carregamento do modulo Expresso Mail

Line 
1<?php
2
3/*
4 * This file is part of the Assetic package, an OpenSky project.
5 *
6 * (c) 2010-2012 OpenSky Project Inc
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Assetic\Filter;
13
14use Assetic\Asset\AssetInterface;
15
16/**
17 * Loads SCSS files using the PHP implementation of scss, scssphp.
18 *
19 * Scss files are mostly compatible, but there are slight differences.
20 *
21 * @link http://leafo.net/scssphp/
22 *
23 * @author Bart van den Burg <bart@samson-it.nl>
24 */
25class ScssphpFilter implements FilterInterface
26{
27    private $compass = false;
28
29    private $importPaths = array();
30
31    public function enableCompass($enable = true)
32    {
33        $this->compass = (Boolean) $enable;
34    }
35
36    public function isCompassEnabled()
37    {
38        return $this->compass;
39    }
40
41    public function filterLoad(AssetInterface $asset)
42    {
43        $root = $asset->getSourceRoot();
44        $path = $asset->getSourcePath();
45
46        $lc = new \scssc();
47        if ($this->compass) {
48            new \scss_compass($lc);
49        }
50        if ($root && $path) {
51            $lc->addImportPath(dirname($root.'/'.$path));
52        }
53        foreach ($this->importPaths as $path) {
54            $lc->addImportPath($path);
55        }
56
57        $asset->setContent($lc->compile($asset->getContent()));
58    }
59
60    public function setImportPaths(array $paths)
61    {
62        $this->importPaths = $paths;
63    }
64
65    public function addImportPath($path)
66    {
67        $this->importPaths[] = $path;
68    }
69
70    public function filterDump(AssetInterface $asset)
71    {
72    }
73}
Note: See TracBrowser for help on using the repository browser.