<p>I just started using this snippet with Django 1.3 and it seemed to be working well until I used it with offline compression of static assets.</p>
<p>After a lot of debugging I managed to find the problem; the IfNode class in your implementation does not implement the "nodelist" property. If found this while looking at the Django 1.4 implementation of IfNode.</p>
<p>This fixes the issue:</p>
<pre>class IfNode(Node):
def __init__(self, branches):
self.branches = branches
def __repr__(self):
return "<If node>"
def __iter__(self):
for branch in self.branches:
for node in branch.node_list:
yield node
@property
def nodelist(self):
return NodeList(self.__iter__())
def render(self, context):
for n in self.branches:
var = n.var
if var is not True:
try:
var = var.eval(context)
except VariableDoesNotExist:
var = None
if var:
return n.node_list.render(context)
return ""
</pre>