Skip to content

Instantly share code, notes, and snippets.

@janmarek
Created November 11, 2010 21:45
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save janmarek/673258 to your computer and use it in GitHub Desktop.
Save janmarek/673258 to your computer and use it in GitHub Desktop.
LessFilter pro WebLoader
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.
<?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