From c7fd750388b22dc28509cfab05f7e5edd077d286 Mon Sep 17 00:00:00 2001 From: Serghei MIHAI Date: Mon, 8 Sep 2014 18:19:04 +0200 Subject: [PATCH] handling properly cases when no template defined --- src/cmsplugin_blurp/renderers/template.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/cmsplugin_blurp/renderers/template.py b/src/cmsplugin_blurp/renderers/template.py index df1f63e..3d78a72 100644 --- a/src/cmsplugin_blurp/renderers/template.py +++ b/src/cmsplugin_blurp/renderers/template.py @@ -30,16 +30,15 @@ class TemplateRenderer(BaseRenderer): '''First try to get a template by path, then compile the inline template, and if none of that works show an error message.''' - if 'template_name' in self.config: + if 'template' in self.config: + template = Template(self.config['template']) + elif 'template_name' in self.config: try: template = get_template(self.config['template_name']) except TemplateDoesNotExist: - pass - elif 'template' in self.config: - template = Template(self.config['template']) - else: - log.error('template not found: %r', self.config) - template = 'cmsplugin_blurp/template_not_found.html' + log.error('template not found: %r', self.config) + template = 'cmsplugin_blurp/template_not_found.html' + if settings.TEMPLATE_DEBUG: if not hasattr(template, 'render'): template = get_template(template)