Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

114
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda