jae-blog/templates/macros.askama

31 lines
1 KiB
Text

{% macro span_date(value) %}
<span class="{%- match df -%}
{% when DateFormat::RFC3339 %}
date-rfc3339
{% when DateFormat::Strftime(_) %}
{%- endmatch -%}">{{ value|date(df) }}</span>
{% endmacro %}
{% macro table(post) %}
<div class="table">
{% match post.created_at %}
{% when Some(created_at) %}
<div class="created">written</div>
<div class="created value">{% call span_date(created_at) %}</div>
{% when None %}
{% endmatch %}
{% match post.modified_at %}
{% when Some(modified_at) %}
<div class="modified">last modified</div>
<div class="modified value">{% call span_date(modified_at) %}</div>
{% when None %}
{% endmatch %}
{% if !post.tags.is_empty() %}
<div class="tags">tags</div>
<div class="tags value">
{% for tag in post.tags %}
<a href="/?tag={{ tag }}" title="view all posts with this tag">{{ tag }}</a>
{% endfor %}
</div>
{% endif %}
</div>
{% endmacro %}