I want to add multiple jinja2 etensions but I don’t know the syntax. This is my current config:
config = { 'webapp2_extras.sessions': {
'cookie_name': '_simpleauth_sess',
'secret_key': SESSION_KEY
},
'webapp2_extras.auth': {
'user_attributes': []
},'webapp2_extras.jinja2': {'template_path': 'templates',
'filters': {'timesince': filters.timesince,
'datetimeformat': filters.datetimeformat,
'slugify_montao' : filters.slugify_montao,
'format_datetime_human' : filters.format_datetime_human,
'default_if_none' : filters.default_if_none,
'datetimeformat_viewad': filters.datetimeformat_viewad,
'datetimeformat_jinja': filters.datetimeformat_jinja,
},
'environment_args': {'extensions': ['jinja2.ext.i18n']}},
'webapp2_extras.sessions': {'secret_key': 'my-245-key'}}
I want to add the entension env = Environment(extensions=['jinja2htmlcompress.SelectiveHTMLCompress']) but I don’t know how to have more than one. Can you show me?
Thank you
http://jinja.pocoo.org/docs/extensions/
Update
Seeing the answer below, I’ve edited my config object to this:
config = { ‘webapp2_extras.sessions’: {
‘cookie_name’: ‘_simpleauth_sess’,
‘secret_key’: SESSION_KEY }, ‘webapp2_extras.auth’: {
‘user_attributes’: [] },’webapp2_extras.jinja2′: {‘template_path’: ‘templates’,
‘filters’: {‘timesince’: filters.timesince,
‘datetimeformat’: filters.datetimeformat, ‘slugify_montao’ : filters.slugify_montao, ‘format_datetime_human’ :
filters.format_datetime_human, ‘default_if_none’ :
filters.default_if_none, ‘datetimeformat_viewad’:
filters.datetimeformat_viewad, ‘datetimeformat_jinja’:
filters.datetimeformat_jinja, },
‘environment_args’: {‘extensions’: [‘jinja2.ext.i18n’, ‘jinja2htmlcompress.SelectiveHTMLCompress’]}},
}
Multiple extensions can be specified as additional elements of the original list.
I have to say, though, your
configdictionary appears to be irregularly formatted.One problem in particular is that you appear to have two
'webapp2_extras.sessions'keys which will not work.