{"action":"created","issue":{"url":"https://api.github.com/repos/sunng87/handlebars-rust/issues/43","labels_url":"https://api.github.com/repos/sunng87/handlebars-rust/issues/43/labels{/name}","comments_url":"https://api.github.com/repos/sunng87/handlebars-rust/issues/43/comments","events_url":"https://api.github.com/repos/sunng87/handlebars-rust/issues/43/events","html_url":"https://github.com/sunng87/handlebars-rust/issues/43","id":110722229,"number":43,"title":"Get Array Length","user":{"login":"Gyscos","id":564903,"avatar_url":"https://avatars.githubusercontent.com/u/564903?v=3","gravatar_id":"","url":"https://api.github.com/users/Gyscos","html_url":"https://github.com/Gyscos","followers_url":"https://api.github.com/users/Gyscos/followers","following_url":"https://api.github.com/users/Gyscos/following{/other_user}","gists_url":"https://api.github.com/users/Gyscos/gists{/gist_id}","starred_url":"https://api.github.com/users/Gyscos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Gyscos/subscriptions","organizations_url":"https://api.github.com/users/Gyscos/orgs","repos_url":"https://api.github.com/users/Gyscos/repos","events_url":"https://api.github.com/users/Gyscos/events{/privacy}","received_events_url":"https://api.github.com/users/Gyscos/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-10-09T19:28:21Z","updated_at":"2015-10-10T03:17:43Z","closed_at":null,"body":"Handlebars support accessing an array length:\r\n```\r\nList length: {{my_list.length}}\r\n{{#each my_list}}...{{/each}}\r\n```\r\n\r\n(For instance see http://stackoverflow.com/questions/15428584/how-to-find-array-length-inside-the-handlebar-templates)\r\n\r\nIt seems this is currently not supported in handlebars-rust.\r\n\r\nThe workaround I used was to add a `length` custom helper (candidate for built-in helpers?), but maybe following the original syntax would also be a good idea?"},"comment":{"url":"https://api.github.com/repos/sunng87/handlebars-rust/issues/comments/147027769","html_url":"https://github.com/sunng87/handlebars-rust/issues/43#issuecomment-147027769","issue_url":"https://api.github.com/repos/sunng87/handlebars-rust/issues/43","id":147027769,"user":{"login":"sunng87","id":221942,"avatar_url":"https://avatars.githubusercontent.com/u/221942?v=3","gravatar_id":"","url":"https://api.github.com/users/sunng87","html_url":"https://github.com/sunng87","followers_url":"https://api.github.com/users/sunng87/followers","following_url":"https://api.github.com/users/sunng87/following{/other_user}","gists_url":"https://api.github.com/users/sunng87/gists{/gist_id}","starred_url":"https://api.github.com/users/sunng87/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sunng87/subscriptions","organizations_url":"https://api.github.com/users/sunng87/orgs","repos_url":"https://api.github.com/users/sunng87/repos","events_url":"https://api.github.com/users/sunng87/events{/privacy}","received_events_url":"https://api.github.com/users/sunng87/received_events","type":"User","site_admin":false},"created_at":"2015-10-10T03:17:43Z","updated_at":"2015-10-10T03:17:43Z","body":"In rust we only have a JavaScript type system, but no expression support built-in. Currently you can use a helper like this (not tested):\r\n\r\n```rust\r\n// implement via bare function\r\nfn another_simple_helper (c: &Context, h: &Helper, _: &Handlebars, rc: &mut RenderContext) -> Result<(), RenderError> {\r\n    let param = h.params().get(0).unwrap();\r\n    let value = c.navigate(rc.get_path(), param);\r\n    try!(rc.writer.write(value.as_array().unwrap().len().to_string().into_bytes().as_ref()));\r\n    Ok(())\r\n}\r\n```\r\nSupporting these **special** properties in `context.navigate` is also a good idea. But we may need to implement all javascript native properties. Currently I have no idea about how much work it needs. "}}