I cannot get LESS to correctly parse a variable and then pass it to javascript.
@bp1 : "lorem";
@bp2 : "ipsum";
@bp3 : "foo";
@bp4 : "bar";
@bp5 : "baz";
@bp6 : "ham";
@bpN: 6;
.loopingClass (@index) when (@index > 0) {
@val: ~'@{bp@{index}}';
@value: ~'"@{val}".toUpperCase()';
@media screen and (min-width: @value) {
body { font-family: ~'"@{bp@{index}}"'; }
}
.loopingClass(@index - 1);
}
.loopingClass (0) {}
.loopingClass (@bpN);
The follow code results in:
@media screen and (min-width: "ham".toUpperCase()) {
body {
font-family: "ham";
}
}
@media screen and (min-width: "baz".toUpperCase()) {
body {
font-family: "baz";
}
}
@media screen and (min-width: "bar".toUpperCase()) {
body {
font-family: "bar";
}
}
@media screen and (min-width: "foo".toUpperCase()) {
body {
font-family: "foo";
}
}
@media screen and (min-width: "ipsum".toUpperCase()) {
body {
font-family: "ipsum";
}
}
@media screen and (min-width: "lorem".toUpperCase()) {
body {
font-family: "lorem";
}
}
I'm trying to dynamically set the variable, and then interact with it with javascript. What am I missing here? Is this even possible with LESS?