I'm using Google App Engine's version of Django templates in Python.
Is there a major performance difference between putting loops in the template vs putting it in the python page handlers?
For example, I'm comparing something like this:
{% for i in items %}
<div id="item_{{i.key}}">
{{i.text}}
</div>
{% endfor %}
Vs something like this inside my python code:
def returnHtml(items):
item_array = []
for i in items:
item_array.append("<div id='item_%s'>%s</div>" % (i.id, i.text)
return "".join(item_array)
... which then gets directly inserted into a django template in a tag like:
{{ item_html }}
This is a trivial example, realistically, I've got more complex loops inside of loops, etc. I like putting the logic inside of the python code because it's much easier to maintain. But I'm worried about the impact on performance.
Any thoughts? Thanks.