{"action":"created","issue":{"url":"https://api.github.com/repos/wycats/handlebars.js/issues/986","labels_url":"https://api.github.com/repos/wycats/handlebars.js/issues/986/labels{/name}","comments_url":"https://api.github.com/repos/wycats/handlebars.js/issues/986/comments","events_url":"https://api.github.com/repos/wycats/handlebars.js/issues/986/events","html_url":"https://github.com/wycats/handlebars.js/issues/986","id":63972641,"number":986,"title":"Get the nested property count","user":{"login":"email2vimalraj","id":1214686,"avatar_url":"https://avatars.githubusercontent.com/u/1214686?v=3","gravatar_id":"","url":"https://api.github.com/users/email2vimalraj","html_url":"https://github.com/email2vimalraj","followers_url":"https://api.github.com/users/email2vimalraj/followers","following_url":"https://api.github.com/users/email2vimalraj/following{/other_user}","gists_url":"https://api.github.com/users/email2vimalraj/gists{/gist_id}","starred_url":"https://api.github.com/users/email2vimalraj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/email2vimalraj/subscriptions","organizations_url":"https://api.github.com/users/email2vimalraj/orgs","repos_url":"https://api.github.com/users/email2vimalraj/repos","events_url":"https://api.github.com/users/email2vimalraj/events{/privacy}","received_events_url":"https://api.github.com/users/email2vimalraj/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-03-24T11:28:13Z","updated_at":"2015-03-24T15:58:04Z","closed_at":"2015-03-24T15:58:04Z","body":"Consider this as more of like a question, rather than an issue.\r\n\r\nI have a json data as follows:\r\n\r\n    var myJson = {\r\n        \"features\": [\r\n          {\r\n            \"id\": 1,\r\n            \"result\": \"pass\",\r\n            \"scenarios\": [\r\n              {\r\n                  \"id\": \"Scenario-1\",\r\n                  \"steps\": [\r\n                    {\r\n                       \"id\": \"Step-1\"\r\n                    },\r\n                    {\r\n                       \"id\": \"Step-2\"\r\n                    }\r\n                  ]\r\n              },\r\n              {\r\n                  \"id\": \"Scenario-2\",\r\n                  \"steps\": [\r\n                    {\r\n                       \"id\": \"Step-3\"\r\n                    },\r\n                    {\r\n                       \"id\": \"Step-4\"\r\n                    },\r\n                    {\r\n                       \"id\": \"Step-5\"\r\n                    },\r\n                    {\r\n                       \"id\": \"Step-6\"\r\n                    }\r\n                  ]\r\n              }\r\n            ]\r\n          }\r\n       ]\r\n    }\r\n\r\nI created a custom helper to get the scenario count as follows:\r\n\r\n    Handlebars.registerHelper('totalTestCount', function(items) {\r\n        var totalTest = 0;\r\n\r\n        for (var i = 0; i < items.length; i++) {\r\n            totalTest += items[i].scenarios.length;\r\n        };\r\n\r\n        return totalTest;\r\n    });\r\n\r\nBut I'm unhappy with the implementation. Because, I have to implement another custom helper to get the steps count which is nested to scenarios.\r\n\r\nSo what do I want to achieve is, I would like to create the template as:\r\n\r\n    <p>{{#totalCount features scenarios}}{{/totalCount}}</p>\r\n\r\nshould be rendered as:\r\n\r\n    <p>2</p>\r\n\r\nIf there is any nested property inside the scenarios, then the template will be:\r\n\r\n    <p>{{#totalCount features scenarios steps}}{{/totalCount}}</p>\r\n\r\nshould be rendered as, for example:\r\n\r\n    <p>6</p>\r\n\r\nI'm not sure whether this is possible or not. Please let me know on how to approach this."},"comment":{"url":"https://api.github.com/repos/wycats/handlebars.js/issues/comments/85574295","html_url":"https://github.com/wycats/handlebars.js/issues/986#issuecomment-85574295","issue_url":"https://api.github.com/repos/wycats/handlebars.js/issues/986","id":85574295,"user":{"login":"kpdecker","id":196390,"avatar_url":"https://avatars.githubusercontent.com/u/196390?v=3","gravatar_id":"","url":"https://api.github.com/users/kpdecker","html_url":"https://github.com/kpdecker","followers_url":"https://api.github.com/users/kpdecker/followers","following_url":"https://api.github.com/users/kpdecker/following{/other_user}","gists_url":"https://api.github.com/users/kpdecker/gists{/gist_id}","starred_url":"https://api.github.com/users/kpdecker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kpdecker/subscriptions","organizations_url":"https://api.github.com/users/kpdecker/orgs","repos_url":"https://api.github.com/users/kpdecker/repos","events_url":"https://api.github.com/users/kpdecker/events{/privacy}","received_events_url":"https://api.github.com/users/kpdecker/received_events","type":"User","site_admin":false},"created_at":"2015-03-24T15:58:04Z","updated_at":"2015-03-24T15:58:04Z","body":"I'm not sure what you are asking here, but closing since this is not a bug report or a feature request. I'd recommend asking questions about your implementation concerns in Stack Overflow as there is a bit of a community built around that."}}