My build script compiles my stylus code and includes some data.
stylus(stylFile)
.set('filename', 'index.css')
.define('data', require('./data.json'))
.render(...)
The data.json file contains groups with nested objects representing items.
{
"group1": {
"item1": {
"width": 1
},
"item2": {
"width": 2
}
},
"group2": {
"item3": {
"width": 3
}
}
}
I want to loop through the groups and their respective items in my Stylus file like this:
for group, items in data
#{group}
for id, item in items
#{id}
width item.width
The expected output should be:
#group1 #item1 {
width: 1;
}
#group1 #item2 {
width: 2;
}
#group2 #item3 {
width: 3;
}
However, I encounter an error which says:
ParseError: index.css:118:1
114| #{group}
115| for id, item in items
116| #{id}
117| width item.width
118|
--------^
expected "indent", got "outdent"