From 63f996466bea055979a34b356591a6945f59dc0c Mon Sep 17 00:00:00 2001 From: Armin Ronacher Date: Sun, 4 Mar 2007 20:30:14 +0100 Subject: [PATCH] [svn] updated bakerplugin --HG-- branch : trunk --- jinja/bakerplugin.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/jinja/bakerplugin.py b/jinja/bakerplugin.py index d3d729c..422e47e 100644 --- a/jinja/bakerplugin.py +++ b/jinja/bakerplugin.py @@ -49,6 +49,16 @@ class JinjaPlugin(object): if k.startswith('jinja.loader.'): loaderoptions[k[14:]] = v loader = loadercls(**loaderoptions) + if 'jinja.environment.context_class' in options: + context_class = options['jinja.environment.context_class'] + else: + contextname = options.get('jinja.context_class') or \ + 'jinja.datastructure.Context' + if '.' in contextname: + p = contextname.rsplit('.', 1) + context_class = getattr(__import__(p[0], '', '', ['']), p[1]) + else: + from jinja import Context as context_class self.environment = Environment( block_start_string=options.get('jinja.block_start_string', '{%'), block_end_string=options.get('jinja.block_end_string', '%}'), @@ -63,7 +73,8 @@ class JinjaPlugin(object): namespace=options.get('jinja.namespace'), loader=loader, filters=options.get('jinja.filters'), - tests=options.get('jinja.tests') + tests=options.get('jinja.tests'), + context_class=context_class ) def load_template(self, templatename, template_string=None): -- 2.26.2