- if user_template_path:
- return jinja2.ChoiceLoader(
- [jinja2.FileSystemLoader(user_template_path),
- jinja2.PackageLoader('mediagoblin', 'templates')])
- else:
- return jinja2.PackageLoader('mediagoblin', 'templates')
+ path_list = []
+
+ # Add user path first--this takes precedence over everything.
+ if user_template_path is not None:
+ path_list.append(jinja2.FileSystemLoader(user_template_path))
+
+ # Any theme directories in the registry
+ if current_theme and current_theme.get('templates_dir'):
+ path_list.append(
+ jinja2.FileSystemLoader(
+ current_theme['templates_dir']))
+
+ # Add plugin template paths next--takes precedence over
+ # core templates.
+ if plugin_template_paths is not None:
+ path_list.extend((jinja2.FileSystemLoader(path)
+ for path in plugin_template_paths))
+
+ # Add core templates last.
+ path_list.append(jinja2.PackageLoader('mediagoblin', 'templates'))
+
+ return jinja2.ChoiceLoader(path_list)