Can I suppress newlines after each template tag with Django's template engine?

Posted by ento on Stack Overflow See other posts from Stack Overflow or by ento
Published on 2010-04-09T09:04:53Z Indexed on 2010/04/10 6:13 UTC
Read the original article Hit count: 313

Filed under:
|

In Rails ERB, you can suppress newlines by adding a trailing hyphen to tags:

<ul>
  <% for @item in @items -%>
    <li><%= @item %></li>
  <% end -%>
</ul>

becomes:

<ul>
    <li>apple</li>
    <li>banana</li>
    <li>cacao</li>
</ul>

Is there a way to do this in Django? (Disclosure: I'm generating a csv file with Django)

Edit: Clarified that the newlines I'm hunting down are the ones left behind after the template tags.

© Stack Overflow or respective owner

Related posts about django

Related posts about django-templates