Previous Jinja version has very handy tag that was able to capture the
output: http://wsgiarea.pocoo.org/jinja/docs/utils.html.
Are there any possibilities to add such functionality to Jinja2?
Recently I googled for it, but found nothing, and so I written simple
extension:
class CaptureExtension(Extension):
tags = set(['capture'])
def parse(self, parser):
lineno = parser.stream.next().lineno
target = parser.parse_assign_target()
node = nodes.Concat(lineno=lineno)
body = parser.parse_statements(['name:endcapture'],
drop_needle=True)
node.nodes = body[0].nodes
return nodes.Assign(target, node, lineno=lineno)
It can process simple expression statements like:
{% capture deposit_name %}
<a href="{{ href }}">{{ deposit.name }}</a>
{% endcapture %}
But it doesn't process inner tags. Please, help.
--
You received this message because you are subscribed to the Google Groups
"pocoo-libs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/pocoo-libs?hl=en.