Skip to content

Getting the @index / @first / @last from a root context #107

Closed
dotnet/arcade
#16884

Description

@breenyoung

Maybe I'm gettin the syntax wrong, but anyone know if when you're in a nested each loop you can get at the parent's context of @index/first/last in the parent loop?

{{@each}}

Parent index: {{@index}}

{{#each}}

    How to get at parent @index?
    {{../@index}} ?
    {{@root.index}} ?

{{/each}}

{{/each}}

Activity

  1. rexm commented on Mar 23, 2016

    @rexm
    Member

    Need to figure out why, {{../../@index}} will get you the current parent index. That isn't correct or intuitive, but that's how it seems to work right now.

  2. rexm commented on Mar 25, 2016

    @rexm
    Member

    How does handlebarsjs work in this situation?

  3. imsedim commented on May 11, 2016

    @imsedim
    Contributor

    From here

    Nested each blocks may access the interation variables via depth based paths. To access the parent index, for example, {{@../index}} can be used.

  4. 304NotModified commented on Aug 2, 2019

    @304NotModified
    Contributor

    Isn't this fixed with #174?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions