{"issue":{"title":"Array of Objects: TypeError: Cannot read property 'id' of undefined","user":{"login":"wilsolutions","id":474548,"url":"https://api.github.com/users/wilsolutions","gravatar_id":"0097c840141d77ee5cea662697198c09","avatar_url":"https://secure.gravatar.com/avatar/0097c840141d77ee5cea662697198c09?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png"},"created_at":"2011-11-21T17:23:11Z","milestone":null,"state":"closed","updated_at":"2011-12-27T21:50:59Z","labels":[{"name":"bug","url":"https://api.github.com/repos/wycats/handlebars.js/labels/bug","color":"e10c02"}],"id":2306944,"pull_request":{"patch_url":null,"html_url":null,"diff_url":null},"closed_at":"2011-12-27T21:50:59Z","html_url":"https://github.com/wycats/handlebars.js/issues/142","body":"Hi,\r\n\r\nI have a list of items and each item can have a Photo item or not.\r\n\r\nI'm looping using \"this\"\r\n\r\n\r\nIt is fine when all items have a Photo:\r\n\r\n    <script id='library-template' type=\"text/x-handlebars-template\">\r\n        {{#this}}\r\n            <div class='box'>\r\n                <a href='#insight' data-insight_id=\"{{Item.id}}\">\r\n\t\t\t\t{{#if Photo.0.id }}\r\n\t\t\t\t\t\t{{Photo.0.photo}}\r\n\t\t\t\t{{/if}}\r\n                </a>\r\n\r\n                <div class='subtitle'>\r\n                    <h2>{{Item.title}}</h2>\r\n                    <p>Added: {{Item.created}}</p>\r\n                </div>\r\n            </div>\r\n        {{/this}}\r\n    </script>\r\n\r\nwhen the current object do not have a Photo object.\r\nTypeError: Cannot read property 'id' of undefined\r\n\r\nFormat of my objects:\r\n[\r\nObject\r\n    Item: Object\r\n    Photo: Array[1]\r\n    Rating: Array[0]\r\n    Tag: Array[0]\r\n    __proto__: Object\r\n, \r\nObject\r\n    Item: Object\r\n    Photo: Array[0]\r\n    Rating: Array[0]\r\n    Tag: Array[0]\r\n    __proto__: Object\r\n, \r\nObject\r\n, \r\nObject\r\n, \r\nObject\r\n]\r\n                \r\nThe second Object do not have a Photo record all the other ones have.\r\n\r\nNote: testing {{#if Photo.0}} instead of {{#if Photo.0.id}} results:\r\nError: Parse error on line 5: ...}\"> {{#if Photo.0 }} {{Photo.0 ----------------------^ Expecting 'ID'\r\n","number":142,"url":"https://api.github.com/repos/wycats/handlebars.js/issues/142","comments":3,"assignee":null},"action":"closed"}