Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

98
Vistas
Pug increase the number 'inside' array name

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!

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

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
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda