Skip to content

Instantly share code, notes, and snippets.

@anoxic
Last active December 15, 2015 18:59
Show Gist options
  • Save anoxic/5307889 to your computer and use it in GitHub Desktop.
Save anoxic/5307889 to your computer and use it in GitHub Desktop.
<?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