coffin

How to access context variables from the Jinja's Extension?

早过忘川 提交于 2019-12-10 22:17:57
问题 I'm using django+jinja2 via coffin, and I can't understand how to access the context variables in the extension. For example, I have this: from coffin.shortcuts import render_to_response def some_view(request): return render_to_response('template.html', {'a': 1}) class RenderFooExtension(Extension): tags = set(['render_foo']) def parse(self, parser): lineno = parser.stream.next().lineno # Some parsing process return nodes.Output([self.call_method('render'),]).set_lineno(lineno) def render