Commits

David Chambers  committed a46dc1d

Refactored the index template to avoid the `forloop.counter`, `forloop.last`
nonsense.

  • Participants
  • Parent commits 72d14cf

Comments (0)

Files changed (1)

File templates/index.dhtml

 {% extends "base.dhtml" %}
 {% load mango_extras %}
 {% block header_title %}<h1>{{ SITE_TITLE }}</h1>{% endblock %}
-{% block content %}{% for document in posts %}{% if forloop.counter <= 5 %}{% include "excerpt.dhtml" %}{% else %}{% if forloop.last %}
-            <h2>Want more?</h2>
-            <p>Check out the <a href="{% url mango.views.archives %}">archives</a>.</p>{% endif %}{% endif %}{% empty %}
-            <h2>Welcome to your new blog</h2>
-            <p>It's lookin' a bit empty, though. Get to work!</p>
-{% endfor %}{% endblock %}
+{% block content %}
+    {% for document in posts|slice:":5" %}
+        {% include "excerpt.dhtml" %}
+    {% empty %}
+        <h2>Welcome to your new blog</h2>
+        <p>It's lookin' a bit empty, though. Get to work!</p>
+    {% endfor %}
+    {% if posts|length > 5 %}
+        <h2>Want more?</h2>
+        <p>Check out the <a href="{% url mango.views.archives %}">archives</a>.</p>
+    {% endif %}
+{% endblock %}