I'm using PUG and I have arrays as below
-let filter0 = ['Category', 'Brand', 'Price', 'Color']
-let filter1 = ['Category 1', 'Category 2', 'Category 3']
-let filter2 = ['Brand 1', 'Brand 2']
-let filter3 = ['Price 1', 'Price 2']
-let filter4 = ['Color 1', 'Color 2']
filter0 defines my titles.
The rest (filter#) defines sub categories of each title.
I want to increase the name of array in every loop same as class names.
each val, index in filter0
input(class='toggle' id='toggle'+index type='checkbox')
label.title(for='toggle'+index)
= val
.content
each val, index in filter1 // This should be filter+index so the result can be filter1,filter2 etc.
ul
li
input(class='checkbox' id='checkbox-'+index type='checkbox' value='value'+index)
label(for='checkbox-'+index)= val
Is this possible? Thanks!
For anyone who might want to see the solution for some reason :P Thanks @AminTaghikhani
var filter = {
0: ['Category', 'Brand', 'Price', 'Color'],
1: ['Category 1', 'Category 2', 'Category 3'],
2: ['Brand 1', 'Brand 2'],
3: ['Price 1', 'Price 2'],
4: ['Color 1', 'Color 2']
}
each x, y in filter[0]
input(class='toggle' id='toggle'+y type='checkbox')
label.title(for='toggle'+y)
= x
.content
each a, b in filter[1+y]
ul
li
input(class='checkbox' id='checkbox-'+b+y type='checkbox' value='value'+b+y)
label(for='checkbox-'+b+y)= a