Commits

Andreas Kloeckner committed b1eed94

Factor render_{pagetrail,locationline} into utils.

  • Participants
  • Parent commits 9791423

Comments (0)

Files changed (2)

File MoinMoin/templates/layout.html

 {% extends "base.html" %}
 
 {% import "snippets.html" as snippets with context %}
+{% from "utils.html" import
+    render_locationline, render_pagetrail
+    with context %}
 {% set logo = snippets.logo() %}
 {% set before_header = snippets.before_header() %}
 {% set after_header = snippets.after_header() %}
         {%- endif %}
     </div>
 
-
     <div id="moin-locationline">
-        {% if cfg.show_interwiki -%}
-        <span id="moin-interwiki">
-            <a href="{{ url_for('frontend.show_item', item_name=cfg.item_root) }}" rel="nofollow">
-                {% if cfg.interwikiname %}{{ cfg.interwikiname }}{% else %}Self{% endif %}
-            </a>
-            <span class="sep">: </span>
-        </span>
-        {%- endif %}
-        <span id="moin-pagelocation">
-            <span class="moin-pagepath">
-            {% block pagepath %}
-                {% for segment_name, segment_path, exists in theme_supp.location_breadcrumbs(item_name) -%}
-                    {% if not loop.last -%}
-                        <a href="{{ url_for('frontend.show_item', item_name=segment_path) }}" {% if not exists %}class="moin-nonexistent"{% endif %}>
-                            {{ segment_name|shorten_item_name }}
-                        </a>
-                        <span class="sep">/</span>
-                    {% else %}
-                        {% if title_name %}
-                            {{ title_name }}
-                        {% else %}
-                        <a href="{{ url_for('frontend.show_item', item_name=segment_path) }}" {% if not exists %}class="moin-nonexistent"{% endif %}>
-                            {{ segment_name|shorten_item_name }}
-                        </a>
-                        {%- endif %}
-                    {%- endif %}
-                {%- endfor %}
-            {% endblock %}
-            </span>
-        </span>
+        {{ render_locationline() }}
     </div>
 
     {% set trail_items = theme_supp.path_breadcrumbs() %}
     {% if trail_items %}
         <div id="moin-pagetrail">
-        {% for wiki_name, item_name, item_href, exists, err in trail_items %}
-            {%- if wiki_name -%}
-                <a href="{{ item_href }}"{{ " " }}
-                   title="{{ wiki_name }}"
-                   class="{% if err %}moin-badinterwiki{% else %}moin-interwiki{% endif %}">
-                   {{ item_name|shorten_item_name }}
-                </a>
-            {%- else -%}
-                <a href="{{ url_for('frontend.show_item', item_name=item_name) }}"{{ " " }}
-                   {% if not exists -%}class="moin-nonexistent"{%- endif -%}>
-                   {{ item_name|shorten_item_name }}
-                </a>
-            {%- endif %}
-            {% if not loop.last %}<span class="sep"> &raquo; </span>{% endif %}
-        {% endfor %}
+            {{ render_pagetrail(trail_items) }}
         </div>
     {% endif %}
 

File MoinMoin/templates/utils.html

             {{ forms.render_errors(form) }}
     {{ gen.form.close() }}
 {% endmacro %}
+
+{% macro render_locationline() %}
+    {% if cfg.show_interwiki -%}
+    <span id="moin-interwiki">
+        <a href="{{ url_for('frontend.show_item', item_name=cfg.item_root) }}" rel="nofollow">
+            {% if cfg.interwikiname %}{{ cfg.interwikiname }}{% else %}Self{% endif %}
+        </a>
+        <span class="sep">: </span>
+    </span>
+    {%- endif %}
+    <span id="moin-pagelocation">
+        <span class="moin-pagepath">
+        {% block pagepath %}
+            {% for segment_name, segment_path, exists in theme_supp.location_breadcrumbs(item_name) -%}
+                {% if not loop.last -%}
+                    <a href="{{ url_for('frontend.show_item', item_name=segment_path) }}" {% if not exists %}class="moin-nonexistent"{% endif %}>
+                        {{ segment_name|shorten_item_name }}
+                    </a>
+                    <span class="sep">/</span>
+                {% else %}
+                    {% if title_name %}
+                        {{ title_name }}
+                    {% else %}
+                    <a href="{{ url_for('frontend.show_item', item_name=segment_path) }}" {% if not exists %}class="moin-nonexistent"{% endif %}>
+                        {{ segment_name|shorten_item_name }}
+                    </a>
+                    {%- endif %}
+                {%- endif %}
+            {%- endfor %}
+        {% endblock %}
+        </span>
+    </span>
+{% endmacro %}
+
+{% macro render_pagetrail(trail_items, as_list_items=false) %}
+    {% for wiki_name, item_name, item_href, exists, err in trail_items %}
+        {%- if as_list_items -%}
+            <li>
+        {%- endif -%}
+        {%- if wiki_name -%}
+            <a href="{{ item_href }}"{{ " " }}
+               title="{{ wiki_name }}"
+               class="{% if err %}moin-badinterwiki{% else %}moin-interwiki{% endif %}">
+               {{ item_name|shorten_item_name }}
+            </a>
+        {%- else -%}
+            <a href="{{ url_for('frontend.show_item', item_name=item_name) }}"{{ " " }}
+               {% if not exists -%}class="moin-nonexistent"{%- endif -%}>
+               {{ item_name|shorten_item_name }}
+            </a>
+        {%- endif %}
+        {%- if as_list_items -%}
+            </li>
+        {%- else -%}
+            {% if not loop.last %}<span class="sep"> &raquo; </span>{% endif %}
+        {%- endif -%}
+    {% endfor %}
+{% endmacro %}