specific thing: in yer specificpage
global thing: globally appended!
-something: orother"""
+something: orother
+doubleme: happyhappy"""
# General test, should have global context variable only
result = context_modified_app.get("/modify_context/")
assert result.body.strip() == """General page!
global thing: globally appended!
-lol: cats"""
+lol: cats
+doubleme: joyjoy"""
context['global_append'] = 'globally appended!'
return context
+def double_doubleme(context):
+ if 'doubleme' in context:
+ context['doubleme'] = context['doubleme'] * 2
+ return context
+
def setup_plugin():
routes = [
'setup': setup_plugin,
('modify_context.specific_page',
'contextplugin/specific.html'): append_to_specific_context,
- 'template_global_context': append_to_global_context}
+ 'template_global_context': append_to_global_context,
+ 'template_context_prerender': double_doubleme}
global thing: {{ global_append }}
lol: {{ lol }}
+doubleme: {{ doubleme }}
specific thing: {{ specific_page_append }}
global thing: {{ global_append }}
something: {{ something }}
+doubleme: {{ doubleme }}
return render_to_response(
request,
'contextplugin/specific.html',
- {"something": "orother"})
+ {"something": "orother",
+ "doubleme": "happy"})
def general(request):
return render_to_response(
request,
'contextplugin/general.html',
- {"lol": "cats"})
+ {"lol": "cats",
+ "doubleme": "joy"})