Last active
December 15, 2015 18:59
-
-
Save anoxic/5307889 to your computer and use it in GitHub Desktop.
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 | |
class Twig_Extension_Less extends \Twig_Extension { | |
public function getName() { | |
return 'less'; | |
} | |
public function getFunctions() { | |
return array( | |
'css' => new \Twig_Function_Method($this, 'less_css'), | |
); | |
} | |
public function less_css($file) { | |
$out = substr($file, 0, strrpos($file, '.')) . '.less.css'; | |
lessc::ccompile(getcwd() . $file, getcwd() . $out); | |
return $out; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment