By default, jinja2 autoescapes everything, and I want to stop this. I’m using the following code in a BaseHandler class:
@webapp2.cached_property
def jinja2(self):
# Returns a Jinja2 renderer cached in the app registry.
return jinja2.get_jinja2(app=self.app)
According to the docs, get_jinja2() has a callable “factory” argument which defaults to Jinja2(). I presume I need change this to Jinja2(config={‘autoescape’:False}), but how do you specify arguments for the factory?
You should call
get_jinja2withfactoryset to a callable constructing the jinja instance with your customer parameters: