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

198
Visualizações
In handlebars, how to know if I'm at the last occurence of the parent array

I'm struggling on a little problem of mine in a handlebars project. I am working with a set of nested arrays like so:

[
   [
      [
         {Object: "Object1"},
         {Object: "Object2"}
      ],
      [
         {Object: "Object3"},
         {Object: "Object4"}
      ]
   ],
   [
      [
         {Object: "Object5"},
         {Object: "Object6"}
      ],
      [
         {Object: "Object7"},
         {Object: "Object8"}
      ]
   ],
   [
      [
         {Object: "Object5"},
         {Object: "Object6"}
      ],
      [
         {Object: "Object7"},
         {Object: "Object8"}
      ]
   ]
]

I know i can use the @first and @last booleans to know if I'm at the last element of the currently iterating array.

{{#each foo}}
    <div class='{{#if @first}}first foo{{/if}}
                {{#if @last}} last foo{{/if}}'>
      {{@key}} - {{@index}}
    </div>
{{/each}}

but what if I want to know whether or not I'm on the last element of a parrent array?

{{#each fooParent}}
   {{#each foo}}
       <div class='{{#if @first}}first foo not fooparent{{/if}}
                   {{#if @last}} last foo not fooparent{{/if}}'> <!-- How can I know here 
                                                                      that I am on the 
                                                                      last item of the 
                                                                     fooParent array? --> 
         {{@key}} - {{@index}}
       </div>
   {{/each}}
{{/each}}

anyone know how to "get back" in the arrays to know, for example, if I'm on the last element of parent array?

about 4 years ago · Juan Pablo Isaza
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