[Flask] Jinja environment finalize function
davidnieder at gmx.de
Fri Oct 2 13:16:05 CEST 2015
On 01.10.2015 07:15, S McGraw wrote:
> Jinja allows one to initialize an environment with a
> "finalize" callable, which I want to do to convert None's
> to empty strings before they are output. This is much
> cleaner than than filling my templates with innumerable
> "if none ..." constructs.
> But I don't see in the Flask docs how to do this.
Dont't know if this is the way to go but just patching the jinja
environment works for me:
if arg is None:
app = Flask(__name__)
app.jinja_env.finalize = finalize
More information about the Flask