Thursday, June 2, 2011

Template - counter for if loop

I need to show the heading only one time when forloop executed along
with if-loop;
example:
-------------
data.html
--------------

{% for val in data %}
{% ifnotequal val 2 %}
My Heading
<div> {{val}} </div>
{% endifnotequal %}
{% endfor %}

Input
--------
data=[1,2,3,4,5,2,6]

Excepted Out put:
---------------------------

My heading
1
3
4
5
6

Here "My Heading" shouldn't repeat and it should occur one time. We
can't use forloop.counter/first, since we have a if-loop condition .

Pl let me know how to implement it.

Thanks & Regards,
Jai

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment