You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Alexander Yakovlev 7fda6dcd0b Merge branch 'master' of git:// 7 years ago
classes Merge branch 'master' of git:// 7 years ago
config Added option to use external LESS compiler 8 years ago
vendor Changes and fixes for Kohana 3.2 10 years ago
.gitmodules Changes and fixes for Kohana 3.2 10 years ago Got rid of internal compression 7 years ago
init.php Added option to use external LESS compiler 8 years ago

KO3 LESS Module v.1.1.1

LESS Module is a port of Leaf Corcoran's LESSPHP for Kohana 3 It adopts some of Alex Sancho's Kohana 2.3 Assets Module codes for CSS compression, credits goes to them Thanks to cheeaun for helping out! You might also want to check out another implementation from jeremeamia.

To Use

  1. Put the less module folder in your Modules directory
  2. Include less module in your application's bootstrap: 'less' => MODPATH.'less'
  3. Copy the less config file from /modules/less/config/less.php to your application's config directory
  4. From your less.php config file, put the 'path' to where you want the CSS files compiled / compressed, the folder must be writable
  5. You can set 'compress' to TRUE on your less.php config file if you want your CSS files to be minified

Sample Code

Default less files extension is set in Less::$extension and is .less.

** MODPATH/baseModule/media/css/layout.less **

    @bodyBkgColor: #EEE;

	body {
        background: @bodyBkgColor;

        h1 { font-size: 3em; }

** APPPATH/media/css/style.less **

    @divBkgColor: #DDD;

	.roundedCorners (@radius:8px) {

	div {
        background: @divBkgColor;

        p { .roundedCorners(5px); }

** APPPATH/config/less.php **

    return array(
        // relative PATH to a writable folder to store compiled / compressed css
        // path below will be treated as: DOCROOT . 'media/css/'
        'path'     => 'media/css/',
        'compress' => TRUE,

** In your controller **

    class Controller_Sample extends Controller_Template {

        public $template = 'template';

        public function action_example1()
            // no need to add .less extension
            // you can put your less files anywhere
            $less_files = array

            $this->template->stylesheet = Less::compile($less_files);

        public function action_example2()
            // you can pass just single file
            $this->template->stylesheet = Less::compile(APPPATH.'media/css/style');

** In your template **

        <title>LESS for Kohana</title>
        <?= $stylesheet; // will give me ONE compressed css file located in /media/css/ ?>
        <h1>LESS for Kohana or Kohana for LESS?</h1>


Please report it to the issues tracker..