* create config option for optional jinja2 extensions
* add comments & clarify code for jinja2 extensions Conflicts: mediagoblin/config_spec.ini
This commit is contained in:
parent
2ed6afb048
commit
155d234d95
@ -75,6 +75,12 @@ theme = string()
|
||||
plugin_web_path = string(default="/plugin_static/")
|
||||
plugin_linked_assets_dir = string(default="%(here)s/user_dev/plugin_static/")
|
||||
|
||||
[jinja2]
|
||||
# Jinja2 supports more directives than the minimum required by mediagoblin.
|
||||
# This setting allows users creating custom templates to specify a list of
|
||||
# additional extensions they want to use. example value:
|
||||
# extensions = jinja2.ext.loopcontrols , jinja2.ext.with_
|
||||
extensions = string_list(default=list())
|
||||
|
||||
[storage:publicstore]
|
||||
storage_class = string(default="mediagoblin.storage.filestorage:BasicFileStorage")
|
||||
|
@ -50,6 +50,12 @@ def get_jinja_env(template_loader, locale):
|
||||
if locale in SETUP_JINJA_ENVS:
|
||||
return SETUP_JINJA_ENVS[locale]
|
||||
|
||||
# The default config does not require a [jinja2] block.
|
||||
# You may create one if you wish to enable additional jinja2 extensions,
|
||||
# see example in config_spec.ini
|
||||
jinja2_config = mg_globals.global_config.get('jinja2', {})
|
||||
local_exts = jinja2_config.get('extensions', [])
|
||||
|
||||
# jinja2.StrictUndefined will give exceptions on references
|
||||
# to undefined/unknown variables in templates.
|
||||
template_env = jinja2.Environment(
|
||||
@ -57,7 +63,7 @@ def get_jinja_env(template_loader, locale):
|
||||
undefined=jinja2.StrictUndefined,
|
||||
extensions=[
|
||||
'jinja2.ext.i18n', 'jinja2.ext.autoescape',
|
||||
TemplateHookExtension])
|
||||
TemplateHookExtension] + local_exts)
|
||||
|
||||
template_env.install_gettext_callables(
|
||||
mg_globals.thread_scope.translations.ugettext,
|
||||
|
Loading…
x
Reference in New Issue
Block a user