diff options
Diffstat (limited to 'mediagoblin/tools')
-rw-r--r-- | mediagoblin/tools/pluginapi.py | 9 | ||||
-rw-r--r-- | mediagoblin/tools/template.py | 4 |
2 files changed, 12 insertions, 1 deletions
diff --git a/mediagoblin/tools/pluginapi.py b/mediagoblin/tools/pluginapi.py index 2b8e95f4..99b13ac7 100644 --- a/mediagoblin/tools/pluginapi.py +++ b/mediagoblin/tools/pluginapi.py @@ -154,7 +154,10 @@ class PluginManager(object): else: # In this case, it's actually a single callable---not a # list of callables. - self.hooks.setdefault(hook, []).append(templates) + self.template_hooks.setdefault(hook, []).append(templates) + + def get_template_hooks(self, hook_name): + return self.template_hooks.get(hook_name, []) def register_routes(routes): @@ -235,3 +238,7 @@ def get_config(key): def register_template_hooks(template_hooks): PluginManager().register_template_hooks(template_hooks) + + +def get_hook_templates(hook_name): + return PluginManager().get_template_hooks(hook_name) diff --git a/mediagoblin/tools/template.py b/mediagoblin/tools/template.py index 6e01a7dd..c76ce639 100644 --- a/mediagoblin/tools/template.py +++ b/mediagoblin/tools/template.py @@ -23,6 +23,7 @@ from mediagoblin import mg_globals from mediagoblin import messages from mediagoblin.tools import common from mediagoblin.tools.translate import get_gettext_translation +from mediagoblin.tools.pluginapi import get_hook_templates from mediagoblin.meddleware.csrf import render_csrf_form_token @@ -64,6 +65,9 @@ def get_jinja_env(template_loader, locale): template_env.filters['urlencode'] = url_quote_plus + # allow for hooking up plugin templates + template_env.globals['get_hook_templates'] = get_hook_templates + if exists(locale): SETUP_JINJA_ENVS[locale] = template_env |