You cannot work with objects in the stylus; if you fill an object yourself, you can make two arrays and a function.
The selectors variable is an array of selectors / classes.
The variable sprites is an array of url sprites.
The variable arrLength is the length of the array; it must be the same for the selectors and sprites arrays and do not forget that the score starts from zero.
In the loop, call the function generate , which returns the code for each element of the selectors and sprites array.
You can check the code with Stylus Compiler by inserting it in the left margin by clicking the "Compile stylus" button and css appears in the right window.
Stylus code
selectors = current-project, composition-project, room, terms, documents, command, contact sprites = '../../sprites/1.png', '../../sprites/2.png', '../../sprites/3.png', '../../sprites/4.png', '../../sprites/5.png', '../../sprites/6.png', '../../sprites/7.png' arrLength = 6 generate(selector, sprite) &__{selector} background-image url(sprite) .class for num in 0..arrLength generate(selectors[num], sprites[num])
Compiled stylus
.class__current-project { background-image: url("../../sprites/1.png"); } .class__composition-project { background-image: url("../../sprites/2.png"); } .class__room { background-image: url("../../sprites/3.png"); } .class__terms { background-image: url("../../sprites/4.png"); } .class__documents { background-image: url("../../sprites/5.png"); } .class__command { background-image: url("../../sprites/6.png"); } .class__contact { background-image: url("../../sprites/7.png"); }