From 841ef9ca83d2c5e1eac3f16460b54b789b1a3d9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20PALMIER?= < fp@kapt.mobi> Date: Wed, 22 Jan 2020 17:08:48 +0000 Subject: [PATCH 1/2] FIX : Missing html in context --- djangocms_snippet/cms_plugins.py | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/djangocms_snippet/cms_plugins.py b/djangocms_snippet/cms_plugins.py index 5f4052a8..42b68efd 100644 --- a/djangocms_snippet/cms_plugins.py +++ b/djangocms_snippet/cms_plugins.py @@ -11,13 +11,13 @@ from .models import SnippetPtr -CACHE_ENABLED = getattr(settings, 'DJANGOCMS_SNIPPET_CACHE', False) +CACHE_ENABLED = getattr(settings, "DJANGOCMS_SNIPPET_CACHE", False) class SnippetPlugin(CMSPluginBase): model = SnippetPtr - name = _('Snippet') - render_template = 'djangocms_snippet/snippet.html' + name = _("Snippet") + render_template = "djangocms_snippet/snippet.html" text_enabled = True text_editor_preview = False cache = CACHE_ENABLED @@ -26,6 +26,7 @@ def render(self, context, instance, placeholder): try: if instance.snippet.template: context = context.flatten() + context.update({"html": mark_safe(instance.snippet.html}) t = template.loader.get_template(instance.snippet.template) content = t.render(context) else: @@ -33,18 +34,20 @@ def render(self, context, instance, placeholder): t = template.Template(instance.snippet.html) content = t.render(context) except template.TemplateDoesNotExist: - content = _('Template %(template)s does not exist.') % { - 'template': instance.snippet.template + content = _("Template %(template)s does not exist.") % { + "template": instance.snippet.template } except Exception as e: content = escape(str(e)) - context.update({ - 'placeholder': placeholder, - 'object': instance, - 'html': mark_safe(instance.snippet.html), - 'content': content, - }) + context.update( + { + "placeholder": placeholder, + "object": instance, + "html": mark_safe(instance.snippet.html), + "content": content, + } + ) return context From 28ba7beeb9f36cab1d01fea05add207d01c1f01b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20PALMIER?= < fp@kapt.mobi> Date: Wed, 22 Jan 2020 17:15:25 +0000 Subject: [PATCH 2/2] FIX : Typo error --- djangocms_snippet/cms_plugins.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/djangocms_snippet/cms_plugins.py b/djangocms_snippet/cms_plugins.py index 42b68efd..26a5e37f 100644 --- a/djangocms_snippet/cms_plugins.py +++ b/djangocms_snippet/cms_plugins.py @@ -26,7 +26,7 @@ def render(self, context, instance, placeholder): try: if instance.snippet.template: context = context.flatten() - context.update({"html": mark_safe(instance.snippet.html}) + context.update({"html": mark_safe(instance.snippet.html)}) t = template.loader.get_template(instance.snippet.template) content = t.render(context) else: