{"comment":{"url":"https://api.github.com/repos/webcompat/webcompat.com/comments/13728646","html_url":"https://github.com/webcompat/webcompat.com/commit/7e0305e93c4dc3710b356f70f8f554fbf390c5d3#commitcomment-13728646","id":13728646,"user":{"login":"karlcow","id":505230,"avatar_url":"https://avatars.githubusercontent.com/u/505230?v=3","gravatar_id":"","url":"https://api.github.com/users/karlcow","html_url":"https://github.com/karlcow","followers_url":"https://api.github.com/users/karlcow/followers","following_url":"https://api.github.com/users/karlcow/following{/other_user}","gists_url":"https://api.github.com/users/karlcow/gists{/gist_id}","starred_url":"https://api.github.com/users/karlcow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/karlcow/subscriptions","organizations_url":"https://api.github.com/users/karlcow/orgs","repos_url":"https://api.github.com/users/karlcow/repos","events_url":"https://api.github.com/users/karlcow/events{/privacy}","received_events_url":"https://api.github.com/users/karlcow/received_events","type":"User","site_admin":false},"position":null,"line":null,"path":"","commit_id":"7e0305e93c4dc3710b356f70f8f554fbf390c5d3","created_at":"2015-10-13T00:03:28Z","updated_at":"2015-10-13T00:03:28Z","body":"I was thinking of collections at a point.  Just putting it here for remembering and documenting my thought process.\r\n\r\n```python\r\n>>> from collections import namedtuple\r\n>>> Filter = namedtuple('Filter', ['name', 'dataAttribute', 'label'])\r\n>>> filters = []\r\n>>> filters.append(Filter(name='new', dataAttribute='new', label='New Issues'))\r\n>>> filters.append(Filter(name='needsDiagnosis', dataAttribute='needsdiagnosis', label='Needs Diagnosis'))\r\n>>> filters\r\n[Filter(name='new', dataAttribute='new', label='New Issues'), Filter(name='needsDiagnosis', dataAttribute='needsdiagnosis', label='Needs Diagnosis')]\r\n>>> for filter in filters:\r\n...    print filter.name\r\n... \r\nnew\r\nneedsDiagnosis\r\n```\r\n\r\nok I see in the template, there is a loop:\r\n\r\n``` \r\n      {% for Filter in Filters %}\r\n        {% include \"web_modules/filter.html\" %}\r\n      {% endfor %}\r\n```\r\n\r\nAaaaah… Your initial structure was having a typo. :)\r\n\r\nSo if you want the same syntax than in your template and with my collection code, it should be something along \r\n\r\n``` \r\n      {% for Filter in filters %}\r\n        {% include \"web_modules/filter.html\" %}\r\n      {% endfor %}\r\n```\r\n\r\nHere Filter with a `F` is really an object, aka namedtuple. and filters is a list of object which is not really a constant. \r\n\r\nI guess filters could be defined in __init__ And might be usable elsewhere in the code. That would be a nice opportunity to make things a bit more DRY (Do not Repeat Yourself), but that's a separate issue. \r\n\r\n\r\n"}}