I am using lessphp from http://leafo.net/lessphp/
there are certain files that depending on condition should not be compiled
in style.less
I have:
@import "@{bootstrap}";
@import "layout.less";
@import "grid.less";
@import "color.less";
@import "@{fontawesome}";
@import "@{vars}";
and less var in php
if($bootstrap){
$less->setVariables(array(
"bootstrap" => "'bootstrap.less'",
"fontawesome" => "'font-awesome.less'",
"vars" => "'variables.less'"
));
}
this works well except that when $bootstrap is not there
my css files ends up with
@import "";@import "";@import "";@import "";...
in head ,
how can I convert this to actual lessphp var
@import "bootstrap.less";
and use in my less file like
@{bootstrap}
instead
@import "@{bootstrap}";
so when boostrap is not there i dont endup with empty @import in css file .
I tried
"bootstrap" => "'@import "bootstrap.less";'"
but it is not returning anything
any help is appreciated
I can't see how less variables could be used to manage imports like that. Even if the less compiler resolved the string correctly during compilation, it would most likely not trigger the actual import.
If you leave the logic of managing the imports completely to PHP you could generate a list of import statements based on the configuration and parse them without having imports in less files.