with/include template pattern? seeking best practices
I find myself writing things like this a lot in django templates
{% for e in some_list %}
{% with e as element %}
{% include "single_element.html" %}
{% endwith %}
{% enfor %}
This would be in a template which shows a lists of elements, with another template that renders a single one. The template single_element.html uses element locally. I find this encapsulates my templates well, especially in making single_element.html far more reusable.
I've been doing this for a while and wanted to know if there is a better way I just don't know about. Also, I don't know the performance implications of so many with/include calls. This list could be very long (100s or 1000s).
Thanks!
Ivan Kirigin
http://kirigin.com
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/48yhZIb9P9MJ.
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.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home