NLessController is a Yii controller class enables parsing LESS and SCSS sheets on-the-fly for your application
- parses LESS and SCSS sheets on the fly, you just need to link the sheets as you'd link CSS into the html
- supports 3 parser for LESS: leafo, agar, dresende
- can cache the output
- can minify the output
How to use
- Study LESS
- Download the demo
- From the demo, copy the following files to your application:
- In your /protected/config/main.php, configure the NLessController - see the demo config file
Configuration params in details:
- dev (boolean, default:false)
- If true, re-compiles the LESS files at every request. If false, it recompiles only if the LESS file has been modified since the last compilation (or there's no compiled file in the cache of course).
- fullMinify (boolean, default:false)
- If true, whitespaces + comments will be deleted from the output. If false, only the comments will be removed.
- vendorAlias (srting, default:"application.vendors")
- The alias of the vendors directory contains the LESS and SCSS parsers.
- lessParser (string, default:"lessphp_leafo")
- The parser vendor used. Can be "lessphp_leafo", "lessphp_dresende", "lessphp_agar"
- lessOpt (array)
- Options passed to the LESS vendor
- sassOpt (array)
- Options passed to the SCSS vendor
- In your html, link the .less files as it was css.
You may also append a "dev" or "prod" url param you can override the "dev" config param with.
<link rel="stylesheet" type="text/css" href="common.less" /> <link rel="stylesheet" type="text/css" href="screen.less?prod" /> <link rel="stylesheet" type="text/css" href="nav.less?dev" />
Download, comment & rate latest NLessController from its Yii extension page