stylus / nib

Stylus mixins, utilities, components, and gradient image generation
http://stylus.github.io/nib
MIT License
1.9k stars 250 forks source link

Dynamic data attributes (sprintf) #163

Closed ameliemaia closed 11 years ago

ameliemaia commented 11 years ago

Hey,

I can't seem to sprintf variables in data attribute's in Stylus. See example:

div.container
    for $index in 1 .. 5
        .el[data-id="%s" % $index]
            content: $index

The above renders:

div.container .el[data-id="%s" % $index] {
  content: 1;
}
div.container .el[data-id="%s" % $index] {
  content: 2;
 }
div.container .el[data-id="%s" % $index] {
  content: 3;
}    
div.container .el[data-id="%s" % $index] {
  content: 4;
}
div.container .el[data-id="%s" % $index] {
  content: 5;
}

I imagine it's got something to do with the attribute being inside brackets [ ]. Is this a bug or am I missing something?

Cheers,

kizu commented 11 years ago

Just wrap it in interpolation — {"%s" % $index} would work fine. BTW, it's not nib, but Stylus and you should post such issues to http://stackoverflow.com, not in GitHub :)

ameliemaia commented 11 years ago

My bad. I''ll move the discussion elsewhere : )