From 90e44c161c9402c75998490337883b3b8e4193e0 Mon Sep 17 00:00:00 2001 From: Vladislav Manchev Date: Sat, 21 Nov 2015 19:13:25 +0200 Subject: [PATCH] Adding request context to scribble context --- scribbler/templatetags/scribbler_tags.py | 4 ++-- scribbler/views.py | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/scribbler/templatetags/scribbler_tags.py b/scribbler/templatetags/scribbler_tags.py index c2b660e..63dbb6b 100644 --- a/scribbler/templatetags/scribbler_tags.py +++ b/scribbler/templatetags/scribbler_tags.py @@ -61,7 +61,7 @@ def render(self, context): scribble_template = template.engines['django'].from_string(self.raw) else: scribble_template = template.Template(self.raw) - scribble_context = build_scribble_context(scribble) + scribble_context = build_scribble_context(scribble, context) content = scribble_template.render(scribble_context, request) wrapper_template = template.loader.get_template('scribbler/scribble-wrapper.html') context['scribble'] = scribble @@ -175,7 +175,7 @@ def scribble_field(context, model_instance, field_name): scribble_template = template.engines['django'].from_string(field_value) else: scribble_template = template.Template(field_value) - scribble_context = build_scribble_context(None) + scribble_context = build_scribble_context(None, context) rendered_content = scribble_template.render(scribble_context, request) context['rendered_scribble'] = rendered_content diff --git a/scribbler/views.py b/scribbler/views.py index 5d5fbbf..a59f70d 100644 --- a/scribbler/views.py +++ b/scribbler/views.py @@ -17,11 +17,11 @@ from .utils import get_variables -def build_scribble_context(scribble): +def build_scribble_context(scribble, context={}): "Create context for rendering a scribble or scribble preview." - context = { + context.update({ 'scribble': scribble, - } + }) return context