I am using Coffin to integrate Jinja2 with a Django application. I want to use the sorl application in my Jinja2 template. So I decided to write my own extension for the {% thumbnail%} tag. I decided to use the excellent WithExtension as an example that goes out of the box with Coffin.
My extension:
class ThumbnailExtension(Extension): tags = set(['thumbnail']) def parse(self, parser): lineno = parser.stream.next().lineno value = parser.parse_expression() im = get_thumbnail(value.value, "100x100") parser.stream.expect('name:as') name = parser.stream.expect('name') body = parser.parse_statements(['name:endthumbnail'], drop_needle=True)
My template:
{% thumbnail "jinja.png" as img %} {{ img.url }} {% endthumbnail %}
But I get AttributeError: 'ImageFile' object has no attribute 'iter_child_nodes'
It seems that I should pass the jinja2.nodes.Node object as the second parameter to node.ssss (). How can I do it?
source share