Quote:
Originally Posted by NullPointer
I don't see the point in deploying it client side since it really only exists to make developer's lives easier. Just compile it to css and sidestep the JS issues all together.
|
To me, that's too much of a hassle. It would work, but it would defeat the purpose of using LESS in the first place. The variables in LESS make CSS so much easier, but usually what I do to avoid that is use a style.php, and include() that in a <style> tag. Messy, but it works with PHP variables in the CSS code.
EDIT: Something like this:
Normal style.css:
Code:
body{
background:$css_mainColor1;
color:$css_textColor1;
font-size:$css_mainFontSize;
}
As you can see, those PHP variables won't work, even if they exist. .css files aren't parsed as PHP (but you could probably make it so they are in .htaccess). Using this simple fix:
Renamed to style.php:
Code:
body{
background:$css_mainColor1;
color:$css_textColor1;
font-size:$css_mainFontSize;
}
Included in index.php or wherever you need styling (maybe a main header.php file?)
PHP Code:
$css_mainColor1 = '#000'; $css_textColor1 = '#fff'; $css_mainFontSize = '14px'; echo '<style type="text/css">'; include('style.php'); echo '</style>';
To make the variables work.
Last edited by Physicsguy; 06-02-2012 at 08:25 PM..
|