So I'm trying to make a custom-filter in Flask, I am not sure if I can use custom filters with blueprints, so I just put it in my app config, because I can't use @app decorator in other files.
def configure_jinja2(app):
urlize = app.jinja_env.filters['urlize']
truncate = app.jinja_env.filters['truncate']
@app.template_filter('myfilter')
def myfilter(s, trim=False, trunc=255):
s = urlize(s)
if trim:
s = truncate(s, trunc)
return s
So I'm trying to combine 2 built-in jinja2 filters, to create a new custom filter that will also do other stuff.
This gives an error: TypeError: do_urlize() takes at least 2 arguments (1 given)
What do I put in for eval_context?
https://github.com/mitsuhiko/jinja2/blob/master/jinja2/filters.py