Created
September 23, 2016 16:51
-
-
Save JonnatasCabral/2b69ab4e9bb6d5f23e10411c12ad84b3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from django import template | |
| register = template.Library() | |
| @register.inclusion_tag('templatetags/filters.html', takes_context=True) | |
| def filter(context): | |
| list_filters = [] | |
| dict_filters = [] | |
| for f in context['filters']: | |
| if isinstance(f[1], tuple): | |
| dict_filters.append(f) | |
| else: | |
| list_filters.append(f) | |
| context.update({ | |
| 'list_filters': list_filters, | |
| 'dict_filters': dict_filters, | |
| }) | |
| return context | |
| @register.filter(name='split') | |
| def split(value): | |
| return value.split('_')[0] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment