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?