changeset 1766:b78098593483

templates/index.html: Add macro render_entry. Code is taken from the "content" block, and may be useful at other places.
author Cheer Xiao <xiaqqaix@gmail.com>
date Sat, 01 Sep 2012 20:58:26 +0800
parents 54160346e469
children 54be46b8a0b4
files MoinMoin/templates/index.html
diffstat 1 files changed, 23 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/templates/index.html	Sat Sep 01 20:56:57 2012 +0800
+++ b/MoinMoin/templates/index.html	Sat Sep 01 20:58:26 2012 +0800
@@ -69,6 +69,28 @@
     </div>
 {% endblock %}
 
+{% macro render_entry(e) %}
+    {% set maxchars = 20 %}
+    <div>
+        <span class="moin-select-item">&nbsp;</span>
+        {% set mimetype = "application/x.moin.download" %}
+        <a href="{{ url_for('.download_item', item_name=e.meta['name'], mimetype=mimetype) }}" class="moin-download-link">
+        </a>
+        <a href="{{ url_for('.show_item', item_name=e.meta['name']) }}"
+           {# TODO .moin-itemtype-* classes are not styled yet #}
+           class="{{ e.meta['contenttype']|contenttype_to_class }} moin-itemtype-{{ e.meta['itemtype'] }} moin-item"
+           title="{{ e.relname }}">
+           {{ e.relname|truncate(maxchars, true, '..') }}
+        </a>
+        {% if e.hassubitems %}
+            <a href="{{ url_for('frontend.index', item_name=e.meta['name']) }}"
+               title="{{ _("More") }}"
+               class="moin-more-index">&nbsp;
+        </a>
+        {% endif %}
+    </div>
+{% endmacro %}
+
 {% block content %}
     <div class="moin-index-message"><span></span></div>
     {{ self.action_bars() }}
@@ -113,26 +135,8 @@
         {% endfor %}
     </div>
     <div class="moin-item-index">
-        {% set maxchars = 20 %}
         {% for e in index %}
-            <div>
-                <span class="moin-select-item">&nbsp;</span>
-                {% set mimetype = "application/x.moin.download" %}
-                <a href="{{ url_for('.download_item', item_name=e.meta['name'], mimetype=mimetype) }}" class="moin-download-link">
-                </a>
-                <a href="{{ url_for('.show_item', item_name=e.meta['name']) }}"
-                   {# TODO .moin-itemtype-* classes are not styled yet #}
-                   class="{{ e.meta['contenttype']|contenttype_to_class }} moin-itemtype-{{ e.meta['itemtype'] }} moin-item"
-                   title="{{ e.relname }}">
-                   {{ e.relname|truncate(maxchars, true, '..') }}
-                </a>
-                {% if e.hassubitems %}
-                    <a href="{{ url_for('frontend.index', item_name=e.meta['name']) }}"
-                       title="{{ _("More") }}"
-                       class="moin-more-index">&nbsp;
-                </a>
-                {% endif %}
-            </div>
+            {{ render_entry(e) }}
         {% endfor %}
     </div>
     <div class="moin-clr"></div>