Two Scoops of Django: Best Practices for Django 1.5 by Daniel Greenfeld & Audrey Roy

Two Scoops of Django: Best Practices for Django 1.5 by Daniel Greenfeld & Audrey Roy

Author:Daniel Greenfeld & Audrey Roy
Language: eng
Format: mobi, epub
Tags: Django
Publisher: Two Scoops Press
Published: 2013-01-16T16:00:00+00:00


* * *

A better way of writing the above snippet is to use indentation and one operation per line to create a readable, maintainable template:

* * *

Example 12.9 {# Use indentation/comments to ensure code quality #} {# start of list elements #} {% if list_type=="unordered" %} <ul> {% else %} <ol> {% endif %} {% for syrup in syrup_list %} <li class="{{ syrup.temperature_type|roomtemp }}"> <a href="{% url ’syrup_detail’ syrup.slug %}"> {% syrup.title %} </a> </li> {% endfor %} {# end of list elements #} {% if list_type=="unordered" %} </ul> {% else %} </ol> {% endif %}



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.