Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

192
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!