0

Is there any way to throw a javascript expression's output (which is a series of classes) into the CSS generated by LESS? For example, i want to output:

.grid_1 { .grd(1); } .grid_2 { .grd(2); } .grid_3 { .grd(3); } .grid_4 { .grd(4); } .grid_5 { .grd(5); } .grid_6 { .grd(6); } .grid_7 { .grd(7); } .grid_8 { .grd(8); } .grid_9 { .grd(9); } .grid_10 { .grd(10); } .grid_11 { .grd(11); } .grid_12 { .grd(12); }

......by including this code in LESS:

`(function(b){var a="";for(i=1;i<b;i++)a+=".grid_"+i+" { .grd("+i+"); }\n";return a})(12)`;
1
  • Expanded form of the js: (function(columns){ var out=''; for(i=1;i<columns+1;i++){ out+=".grid_"+i+" { .grd("+i+"); }\n"; } return out; })(12); Commented Dec 15, 2011 at 13:22

1 Answer 1

1

I do not think this is possible with LESS. The extent of the JavaScript evaluation appears to just work for variables and CSS properties.

Sign up to request clarification or add additional context in comments.

2 Comments

Yup. That seems true. Thanks.
No problem. I wish it did work though. It would make things like grids so much easier to generate. Maybe it will be implemented at some point. You could possibly drop it into GitHub issues if you really wanted it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.