Created
March 6, 2012 20:41
-
-
Save gazpachoking/1988861 to your computer and use it in GitHub Desktop.
FlexGet plugin which adds custom jinja filters
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
| """ | |
| This plugin just registers more functions as jinja filters. You can then use the filters from any | |
| jinja template in FlexGet like normal. e.g. {{afield|myfilter}} | |
| """ | |
| import logging | |
| log = logging.getLogger('my_filters') | |
| def filter_myfilter(val): | |
| return 'blah' | |
| @event('manager.startup', priority=120) | |
| def add_filters(manager): | |
| from flexget.utils.template import environment | |
| for name, filt in globals().items(): | |
| if name.startswith('filter_'): | |
| filtername = name.split('_', 1)[1] | |
| log.debug('adding custom jinja filter %s' % filtername) | |
| environment.filters[filtername] = filt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment