• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

151
Views
En handlebars, cómo saber si estoy en la última aparición de la matriz principal

Estoy luchando con un pequeño problema mío en un proyecto de manillares. Estoy trabajando con un conjunto de matrices anidadas así:

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

Sé que puedo usar los booleanos @first y @last para saber si estoy en el último elemento de la matriz que se está iterando actualmente.

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

pero ¿qué pasa si quiero saber si estoy o no en el último elemento de una matriz principal ?

 {{#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}}

¿Alguien sabe cómo "regresar" a las matrices para saber, por ejemplo, si estoy en el último elemento de la matriz principal?

almost 3 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 Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error