Issue
I've created a custom filter but my Flask server is getting an internal error.
@app.template_filter('doSomething')
def doSomething(input):
print(input)
return input
HTML
<p>{{ doSomething('Test') }}</p>
Error
jinja2.exceptions.UndefinedError: 'doSomething' is undefined
Solution
After some searching, trial and error, this is the only one that seems to work for me:
def doSomething(input):
print(input)
return input
app.jinja_env.globals.update(doSomething=doSomething)
Answered By - Ari
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.