You could do this: <tr> {% for cell in row %} <td> {% if forloop.first and row.url %}<a href="{{row.url}}">{{cell}}</a> {% else %} {{cell}} {% endif %} </td> {% endfor %} </tr>
On Oct 9, 10:06 am, Chris Withers <ch...@simplistix.co.uk> wrote: > Hi All, > > I have a piece of template that looks like this: > > > <tr> > > {% for cell in row %} > > <td> > > {% if forloop.first and row.url %}<a href="{{row.url}}">{% endif %} > > {{cell}} > > {% if forloop.first and row.url %}</a>{% endif %} > > </td> > > {% endfor %} > > </tr> > > How can I structure this such that I don't have to repeat the condition? > > DRY and all that... > > Chris --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---