Valamas
Valamas

Reputation: 24729

Less Missing closing }

I have the following code and only this code in my Less file.

@iterations: 100;
.width-loop (@i) when (@i > -1) 
{
     (~".w@{i}") 
     {
        width: ~"@{i}%  !important";
     }
    .width-loop(@i - 1);
}
.width-loop(@iterations);

the result is like this.

.w100 {width 100% !important; }
.w99 {width 99% !important; }
...... 

etc

However, when I build my project, this error pops up in my error window.

Less: Missing closing '}'

Where am I missing a }? The error window popping up is most distracting.

When I view the output in the browser, the style classes list correctly.

Upvotes: 0

Views: 239

Answers (1)

pwavg
pwavg

Reputation: 295

You are calling the function wrong. Do it like this:

@iterations: 100;
.width-loop (@i) when (@i > -1) 
{
     .w@{i}
     {
        width: ~"@{i}%  !important";
     }
    .width-loop(@i - 1);
}

.width-loop(@iterations);

Upvotes: 3

Related Questions