PageRenderTime 41ms CodeModel.GetById 36ms app.highlight 1ms RepoModel.GetById 2ms app.codeStats 0ms

/hyde/layouts/basic/layout/macros.j2

http://github.com/hyde/hyde
Jinja | 40 lines | 39 code | 1 blank | 0 comment | 10 complexity | 8c7465f26666a4f956a22262be56fea3 MD5 | raw file
 1{% macro render_excerpt(res, class=None) %}
 2{% refer to res.relative_path as post %}
 3<article {{'class='~class if class }}>
 4<h3><a href="{{ content_url(res.url) }}">{{ res.meta.title }}</a></h3>
 5<a href="{{ content_url(res.url) }}">{{ post.image|markdown|typogrify }}</a>
 6{{ post.excerpt|markdown|typogrify }}
 7<time datetime="{{ res.meta.created.strftime('%Y-%m-%d') }}">
 8    Posted: {{ res.meta.created.strftime('%a, %d %b %Y') }}
 9</time>
10</article>
11{% endmacro %}
12
13{% macro render_nav(menu, cls=None) -%}
14{% if menu -%}
15<nav {{'class='~cls if cls }}>
16    <ul>
17        {% for item in menu -%}
18        {% set active = False -%}
19        {% if item.type == 'page' -%}
20            {% set active = (resource.url ==
21                site.content.resource_from_relative_path(item.url).url) -%}
22        {% else -%}
23            {% set active = (node ==
24                site.content.node_from_relative_path(item.url)) -%}
25        {%- endif %}
26        {% set classes = ['button', 'white'] -%}
27        {% do classes.append('active') if active -%}
28        {% do classes.append(item.css_class) if item.css_class -%}
29        <li>
30            <a title="{{ item.description }}"
31                class="{{ classes|join(' ') }}"
32                href="{{ content_url(item.url) }}">
33                {{ item.name }}
34            </a>
35        </li>
36        {%- endfor %}
37    </ul>
38</nav>
39{%- endif %}
40{%- endmacro %}