laggingreflex
laggingreflex

Reputation: 34627

stylus string interpolation styntax for :before pseudo selector using a for loop

I'm trying to make

#others li .text1:before{
    content: "text1";
}...

by doing

#others li
    for label in text1 text2 text3
        .{label}:before
            content {label}

But syntax isn't right it seems... it gives error

expected "indent", got "outdent"

The error is for content {label} bit, because without it the class selectors (.text1:before) prints ok

And with content '{label}' it prints out {label} as is.

Upvotes: 0

Views: 3252

Answers (1)

kizu
kizu

Reputation: 43224

Stylus don't have interpolation in strings or idents for values, you could use addition to string, this would convert the ident to string:

#others li
    for label in text1 text2 text3
        .{label}:before
            content ''+label

Upvotes: 3

Related Questions