lessclientscript An extension to CClientscript so it parses Less CSS when using registerCSSFile

  1. Requirements
  2. Usage
  3. Resources
  4. Update

With this extension, you can use Less CSS files with registerCSSFile.

The code is based on zsoltlengyelits, LessCSS-for-Yii extension. I've updated it so,

  • it uses the assetsfolder defined by CAssetmanager
  • You have a global caching setting, instead of per file
  • Updated to the latest lessc parser which includes a compress css feature
  • It uses CClientscript to register the outputted css automatically

Requirements

Yii 1.1 or above

Usage

Copy the folder to your extension folder (protected/extensions).

Extend CClientscript:

'components' => array(
        'clientScript' => array(
            'class' => 'ext.LessClientscript.LClientscript',
            'caching' => true, //use the cached css file if available
            'compress' => false, //remove whitespace and linearize to 1 line
		)
	);

Done!

Now you can add it in your view or controller:

Yii::app()->clientScript->registerCSSFile('src/app/admin/stylesheets/test.less');

Resources

Update

V1.02

  • Store temporary less file in runtime folder
  • Fixed bug where if you provided a file with no css in it, it could not find the assets file

V1.01

  • Better commenting
  • Return clientscript object for chaining
  • Refactoring
3 0
4 followers
585 downloads
Yii Version: 1.1
License: GPL-3.0
Category: User Interface
Tags: css, less
Developed by: Zephyr
Created on: Jun 20, 2012
Last updated: 12 years ago

Downloads

show all

Related Extensions