{% 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