Ember V1.0.0-pre.2: capitalization in handlebars templates


#1

We are using Ember V1.0.0-pre.2 and our handlebars is as follows:

{{#each data.Product}}
<div>
  {{Details.uid}} - {{Details.Name}}
</div>

Our the ‘data’ bit is from this json:

{
    "Product": [
        {
            "Details": {
                "uid": "1",
                "Name": "one"
            }
        },
        {
            "Details": {
                "uid": "2",
                "Name": "two"
            }
        },
        {
            "Details": {
                "uid": "3",
                "Name": "three"
            }
        },
        {
            "Details": {
                "uid": "4",
                "Name": "four"
            }
        },
        {
            "Details": {
                "uid": "5",
                "Name": "five"
            }
        }
    ]
}

This fails with the following warning:

WARNING: Watching an undefined global, Ember expects watched globals to be setup by the time the run loop is flushed, check for typos 

When I change ‘Details.whatever’ to ‘details.whatever’ the warning disappears.

Is this by design or can we get around it somehow. The data is returned from the server in a fixed format and we wouldn’t want to use another interim model if we can avoid it.


#2

Are you using Ember Data? If so, you could consider adding a key mapping like so:

DS.RESTAdapter.map('App.Person', {
  lastName: { key: 'lastNameOfPerson' }
});

That way you could keep the capitalized “Details” in your JSON and map it to a lower cased “details” in your model.

More info here: http://emberjs.com/guides/models/the-rest-adapter/#toc_underscored-attribute-names


#3

Hi Marcel,

We are not using Ember data. In the meantime we are using an interim model but it is causing extra work that really one should not need to do :frowning:

Regards, Eben


#4

Hm, okay, in that case I’m afraid I don’t know how to fix this.


#5

This doesn’t seem right, but I’m not using pre2. If you made a minimal JSFiddle that reproduced this, maybe someone will spot the problem or suggest a workaround…