aboutsummaryrefslogtreecommitdiffstats
path: root/mediagoblin/tools/template.py
diff options
context:
space:
mode:
authortilly-Q <nattilypigeonfowl@gmail.com>2013-08-20 12:21:13 -0400
committertilly-Q <nattilypigeonfowl@gmail.com>2013-08-20 12:21:13 -0400
commit9e204e49c9670b0e004dc9b62bf3b698b7534325 (patch)
tree452eab56add0e1b009b665f5b32d7b59b7545e82 /mediagoblin/tools/template.py
parente1561d048815e29b3b7c7e1c860d9cf0c4326f0a (diff)
parentc62d174437445565b55b220396e7571a323a159c (diff)
downloadmediagoblin-9e204e49c9670b0e004dc9b62bf3b698b7534325.tar.lz
mediagoblin-9e204e49c9670b0e004dc9b62bf3b698b7534325.tar.xz
mediagoblin-9e204e49c9670b0e004dc9b62bf3b698b7534325.zip
Merge branch 'master' into OPW-Moderation-Update
Conflicts: mediagoblin/db/models.py mediagoblin/decorators.py mediagoblin/routing.py mediagoblin/user_pages/views.py
Diffstat (limited to 'mediagoblin/tools/template.py')
-rw-r--r--mediagoblin/tools/template.py19
1 files changed, 17 insertions, 2 deletions
diff --git a/mediagoblin/tools/template.py b/mediagoblin/tools/template.py
index 615ce129..fa290611 100644
--- a/mediagoblin/tools/template.py
+++ b/mediagoblin/tools/template.py
@@ -32,7 +32,6 @@ from mediagoblin.tools.timesince import timesince
from mediagoblin.meddleware.csrf import render_csrf_form_token
-
SETUP_JINJA_ENVS = {}
@@ -50,6 +49,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 +62,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,
@@ -84,6 +89,16 @@ def get_jinja_env(template_loader, locale):
template_env.globals = hook_transform(
'template_global_context', template_env.globals)
+ #### THIS IS TEMPORARY, PLEASE FIX IT
+ ## Notifications stuff is not yet a plugin (and we're not sure it will be),
+ ## but it needs to add stuff to the context. This is THE WRONG WAY TO DO IT
+ from mediagoblin import notifications
+ template_env.globals['get_notifications'] = notifications.get_notifications
+ template_env.globals[
+ 'get_notification_count'] = notifications.get_notification_count
+ template_env.globals[
+ 'get_comment_subscription'] = notifications.get_comment_subscription
+
if exists(locale):
SETUP_JINJA_ENVS[locale] = template_env