{"action":"created","issue":{"url":"https://api.github.com/repos/flosch/pongo2/issues/190","repository_url":"https://api.github.com/repos/flosch/pongo2","labels_url":"https://api.github.com/repos/flosch/pongo2/issues/190/labels{/name}","comments_url":"https://api.github.com/repos/flosch/pongo2/issues/190/comments","events_url":"https://api.github.com/repos/flosch/pongo2/issues/190/events","html_url":"https://github.com/flosch/pongo2/issues/190","id":328789066,"node_id":"MDU6SXNzdWUzMjg3ODkwNjY=","number":190,"title":"Is there a filter for array returning the element at specified index?","user":{"login":"shawnye","id":579997,"node_id":"MDQ6VXNlcjU3OTk5Nw==","avatar_url":"https://avatars2.githubusercontent.com/u/579997?v=4","gravatar_id":"","url":"https://api.github.com/users/shawnye","html_url":"https://github.com/shawnye","followers_url":"https://api.github.com/users/shawnye/followers","following_url":"https://api.github.com/users/shawnye/following{/other_user}","gists_url":"https://api.github.com/users/shawnye/gists{/gist_id}","starred_url":"https://api.github.com/users/shawnye/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shawnye/subscriptions","organizations_url":"https://api.github.com/users/shawnye/orgs","repos_url":"https://api.github.com/users/shawnye/repos","events_url":"https://api.github.com/users/shawnye/events{/privacy}","received_events_url":"https://api.github.com/users/shawnye/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-06-03T00:48:33Z","updated_at":"2018-06-27T04:07:17Z","closed_at":null,"author_association":"NONE","body":"The filer named \"index\" for example:\r\n{{ array | index: 3 }}\r\n\r\nIt seems that django is not supported originally, \r\nAny suggestion ? thank you!\r\n\r\ncustom python filter: \r\n<pre>\r\n@register.filter\r\ndef index(l, i):\r\n try:\r\n  return l[i]\r\n except:\r\n  return None\r\n</pre>"},"comment":{"url":"https://api.github.com/repos/flosch/pongo2/issues/comments/400536511","html_url":"https://github.com/flosch/pongo2/issues/190#issuecomment-400536511","issue_url":"https://api.github.com/repos/flosch/pongo2/issues/190","id":400536511,"node_id":"MDEyOklzc3VlQ29tbWVudDQwMDUzNjUxMQ==","user":{"login":"grt1st","id":19374252,"node_id":"MDQ6VXNlcjE5Mzc0MjUy","avatar_url":"https://avatars0.githubusercontent.com/u/19374252?v=4","gravatar_id":"","url":"https://api.github.com/users/grt1st","html_url":"https://github.com/grt1st","followers_url":"https://api.github.com/users/grt1st/followers","following_url":"https://api.github.com/users/grt1st/following{/other_user}","gists_url":"https://api.github.com/users/grt1st/gists{/gist_id}","starred_url":"https://api.github.com/users/grt1st/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/grt1st/subscriptions","organizations_url":"https://api.github.com/users/grt1st/orgs","repos_url":"https://api.github.com/users/grt1st/repos","events_url":"https://api.github.com/users/grt1st/events{/privacy}","received_events_url":"https://api.github.com/users/grt1st/received_events","type":"User","site_admin":false},"created_at":"2018-06-27T04:07:17Z","updated_at":"2018-06-27T04:07:17Z","author_association":"NONE","body":"Try it:\r\n```\r\nfunc init() {\r\n\tpongo2.RegisterFilter(\"index\", filterIndex)\r\n}\r\nfunc filterIndex(in *pongo2.Value, param *pongo2.Value) (*pongo2.Value, *pongo2.Error) {\r\n\tindex := param.Integer()\r\n\treturn pongo2.AsValue(in.Index(index)), nil\r\n}\r\n```\r\n\r\nLearn more at: [https://github.com/flosch/pongo2/blob/9d978217a2f84fab35dd17731da1e1c23be32d14/filters_builtin.go](https://github.com/flosch/pongo2/blob/9d978217a2f84fab35dd17731da1e1c23be32d14/filters_builtin.go)\r\n[https://github.com/flosch/pongo2/blob/9d978217a2f84fab35dd17731da1e1c23be32d14/value.go](https://github.com/flosch/pongo2/blob/9d978217a2f84fab35dd17731da1e1c23be32d14/value.go)\r\n\r\nAlso, a simple way:\r\n\r\n`{{ array.index }}`\r\n\r\nBy the way, any filter needed? I'd be like to contribute some. @flosch "}}
{"actor":{"display_login":"grt1st"}}