On Jul 21, 10:28 pm, truebosko <[EMAIL PROTECTED]> wrote:
> if counter % 2 == 1: Output new row
>
> With this, every 2 items a new row is made so I have 2 items per row.
> Very simple right?
>
> So I tried making a template tag like so
> @register.simple_tag
> def is_new_row(counter):
>     if counter % 2 == 1:
>         return True
>     else:
>         return False
>
> Then in my template I would do:
>
> {% if is_new_row forloop.counter %}
> </tr><tr> ...
> {% endif %}

I don't think you can do that. Custom template tags are meant to be
used sort-of standalone, if i understand them correctly. So you can't
use the result of a custom tag in another tag(if tag in this case).

What you can do, and this is just one way to do it, is something like:
def Inject_new_row(counter):
 if counter % 2 == 1:
         return "<tr>"

Or something like that.
--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to