Skip to content

Glimmer/Handlebars: Clarify glimmer handlebars template syntax (array access by index) #19519

@fpauser

Description

@fpauser

In a project (ember-3.16) I just came across the following snippet:

{{#with item.properties.[0] as |firstProp|}}
  <span>
    {{firstProp.label}}
  </span>
{{/with}}

This works so far, but formatting this thing with the vsc plugin Prettier for handlebars got me

{{#with item.properties.0 as |firstProp|}}
  <span>
    {{firstProp.label}}
  </span>
{{/with}}

which no longer works and triggers a parse error.

To clarify things I looked though the ember docs, but array access by index is not mentioned.

Research in the prettier glimmer/ember-template-lint space resulted in the following statements:

  • .[index] syntax is invalid (but works)
  • .[index] syntax is bad practise
  • .index syntax is invalid and does not work

So the question remains: What is valid/invalid/bad/deprecated glimmer handlebars template syntax? What we are really missing here is a proper glimmer handlebars template syntax specification.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions