Ember handlebars hyphen

I’m getting template error when I use a key with a hyphen in it. Handlebars supports this … Does anyone know how to get that working with Ember?

For an object like this:

   foo =  { "bars": [
                      {"hyphen-key": "value"}
                    ]
          }

and template like this:

{{#each foo.bars as |bar|}}
	<div>{{bar['hyphen-key']}}</div>
{{/each}}

The error is:

Parse error on line 64:
...g >{{foo['hyphen-key']}
-----------------------^
Expecting 'ID', 'STRING', 'NUMBER', 'BOOLEAN', 'UNDEFINED', 'NULL', 'DATA', got 'INVALID'

Broccoli Plugin: broccoli-persistent-filter:TemplateCompiler

Thanks

Ember templates don’t support array syntax like that. Try just {{bar.hyphen-key}} or {{get bar 'hyphen-key'}}

1 Like

Hello @Panman8201 , You try using the get helper.

Something like this: {{get bar "hyphen-key"}}