Yii Less Extension 0.5
Yii Less Extension gives a VERY simple and straight forward way to include LESS files in your Yii view files. Yii Less Extension adds a method to the CClientScript class, namely registerLessFile which is very similary to the registerCssFile method, to directly link LESS files in your Yii view files.
Requires Yii 1.1 or above.
protected/extensions directory of your application.protected/config/main.php under the components section of the config:<?php
return array(
// .....
'components'=>array(
// .....
'clientScript' => array(
'class' => 'ext.yii-less-extension.components.YiiLessCClientScript',
'cache' => true, // Optional parameter to enable or disable LESS File Caching
),
// .....
),
// .....
),
?>
Yii::app()->clientScript->registerLessFile("full-or-relative-path-to-your-less-file/style.less");layouts/main.php will render <web-application-root>/less-files/site.less file as site.css delivered from your assets.<?php Yii::app()->clientScript->registerLessFile(Yii::getPathOfAlias("less-files/site.less")); ?>
<?php Yii::app()->clientScript->registerLess('sample-less', '
body {
padding: 0px;
.container {
margin: 10px;
}
}
'); ?>
generates:
<style type="text/css">
/*<![CDATA[*/
body {
padding: 0px;
}
body .container {
margin: 0px;
}
/*]]>*/
</style>
Total 3 comments
Can it also be used when defining packages?
Files are available for download now: http://www.yiiframework.com/extension/yiilessextension/files/yii-less-extension-0.1.tar.gz
Not avaiable for download?
Leave a comment
Please login to leave your comment.