Is there a way to use JavaScript inside a LESS CSS file..?
What I am currently doing is this :
.f(@l) {
float: @l;
}
#header {
.f(left);
}
What I am trying to achieve is something like this.
.f(@l) {
// use switch or JS function to figure out what @l is and use that.
// for example in this case it could be "l" = left - "r" = right - "n" = none(...)
float: @l;
}
#header {
.f(l);
}
It would be cool even if we could put JS code in the less.js file and then be able to execute it from the .less file (Source)
As a sidenote, I use jQuery on this page as well, if there are any plugins/hacks using it, those are welcome as well. Thanks!
You can embed javascript in your lesscss files (with backticks) details here:
http://lesscss.org/#-javascript-evaluation
Edit: if that link takes you to the top of the page (as it does for me sometimes) search/scroll down to the section titled “Javascript Evaluation”