forked from leafo/lessphp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLessPHP.php
44 lines (40 loc) · 1007 Bytes
/
LessPHP.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
41
42
43
44
<?php
/*
Author : Nicolas Badey
*/
class LessPHP extends lessc {
protected $lessOutput='';
protected $cssCache='';
function createVar($var) {
foreach($var as $key => $value){
$this->cssCache.= '@'.$key.'='. strip_tags(urldecode($value)) . ';'."\n";
}
}
function loadFiles($files) {
foreach ($files as $path){
$path=__DIR__.'/../'.$path;
if (file_exists($path))
$this->cssCache.=file_get_contents($path);
}
}
function writeFile($name,$min=true){
file_put_contents($name,($min==true)?$this->minifie():$this->lessOutput);
}
function minifie(){
return preg_replace("/(\r\n|\n|\r)/", '',$this->lessOutput );
}
function output($min=false){
ob_start('ob_gzhandler');
header('Content-type: text/css');
header("Cache-Control: no-cache, must-revalidate");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
if ($min)
echo $this->minifie();
else
echo $this->lessOutput;
}
function parse($str=null){
$this->lessOutput= parent::parse($this->cssCache);
}
}
?>