Created
November 11, 2010 21:45
-
-
Save janmarek/673258 to your computer and use it in GitHub Desktop.
LessFilter pro WebLoader
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Vyžaduje stáhnutí less kompilátoru tady od nějakého mistra: | |
https://github.com/leafo/lessphp/blob/master/lessc.inc.php | |
-------------- | |
$cssLoader->fileFilters[] = new Webloader\LessFilter; | |
Pro použití ve WebLoaderu je potřeba toto a už to jede. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Webloader; | |
use Nette\String, lessc; | |
/** | |
* Less CSS filter | |
* | |
* @author Jan Marek | |
* @license MIT | |
*/ | |
class LessFilter | |
{ | |
private $lc; | |
private function getLessC() | |
{ | |
if (empty($this->lc)) { | |
$this->lc = new lessc; | |
} | |
return $this->lc; | |
} | |
/** | |
* Invoke filter | |
* @param string code | |
* @param WebLoader loader | |
* @param string file | |
* @return string | |
*/ | |
public function __invoke($code, WebLoader $loader, $file) | |
{ | |
if (String::endsWith($file, ".less")) { | |
return $this->getLessC()->parse($code); | |
} | |
return $code; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment