Ember handlebars hyphen


#1

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


#2

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