Gret library!
Just one thing: it seems to not check, if an imported .less-file has been updated. That added would be even “more” awesome!
@import "style2.less";This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.
The active forums are here.
August 18, 2010 1:27pm
Subscribe [13]#16 / Aug 27, 2011 4:51pm
Gret library!
Just one thing: it seems to not check, if an imported .less-file has been updated. That added would be even “more” awesome!
@import "style2.less";#17 / Jan 09, 2012 7:35pm
I have been using this wrapper library for Less CSS. It makes updating the core library (lessc.inc.php) less of a pain.
Before starting:
- Download latest LESS CSS for PHP: https://github.com/leafo/lessphp
- Put lessc.inc.php in application/libraries/lessphp/
application/libraries/lessphp.php
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Lessphp
{
var $less;
public function __construct()
{
global $less;
include "application/libraries/lessphp/lessc.inc.php";
$less = new lessc();
}
//public function &object;()
public function object()
{
global $less;
return $less;
}
}Usage in a view:
$this->load->library('lessphp');
//Compile a string
$test = "body { a { color: red } }";
$css = $this->lessphp->object()->parse($test)
//Compile a file (has automatic cache functionality)
$this->lessphp->object()->ccompile('css/site.less','css/site.css');In the above example, there is a css folder in the root of the CodeIgniter install. Adjust paths accordingly if you use something else.
For any other functionality, see the documentation for the LESS CSS for PHP:
http://leafo.net/lessphp/docs/#php_interface
Cheers!
#18 / Sep 22, 2012 2:34pm
nice one, thanx!
I just started using .less and loving it !
still trying to find a way to do something like:background-image: url(@site_url'my_images/back.jpg');
That would be
background-image: url(@{site_url}'my_images/back.jpg');You can define global variables in a separate less file, I call it something like common.less which has all the mixins and variable you want all your less to have access to (at the top of your other less files use the import statement). As for actually passing a variable from PHP to LESS I am not so sure.
#19 / Jul 16, 2013 4:14pm
Am I going blind or is there no download link in the original post..