improved static website

This commit is contained in:
Trilarion
2020-10-08 13:18:15 +02:00
parent 13f8e4fa65
commit 7c79a9bde0
16 changed files with 265 additions and 144 deletions

View File

@ -1,31 +1,40 @@
{# A single line of text with a line break at the end and optionally a format class. (see https://bulma.io/documentation/helpers/typography-helpers/) #}
{# A single piece of text optionally with a format class. (see https://bulma.io/documentation/helpers/typography-helpers/) #}
{%- macro render_text(text) -%}
{%- if 'class' in text -%} {# Enhanced text #}
<span class="{{ text['class'] }}">{{ text['text'] }}</span>
{%- else -%}
{{ text['text'] }}
<span>{{ text['text'] }}</span>
{%- endif -%}
{%- endmacro -%}
{# #}
{%- macro render_icon(icon) -%}
<span class="icon"><i class="icon-{{ icon['class'] }}"></i></span>
{%- endmacro -%}
{# Some text surrounded by a link tag #}
{%- macro render_url(url) -%}
<a href="{{ base['url_to'](url['href']) }}">{{ render_text(url['text']) }}</a>
<a href="{{ base['url_to'](url['href'], url) }}"{% if 'title' in url %} title="{{ url['title'] }}"{% endif %}>{{ render_element(url['content']) }}</a>
{%- endmacro -%}
{# Renders either plain text or a link depending on the type #}
{%- macro render_enumeration_entry(entry) -%}
{%- if entry['type'] == 'text' -%}
{%- macro render_element(entry) -%}
{%- if entry is string -%}
<span>{{ entry }}</span>
{%- elif entry['type'] == 'text' -%}
{{ render_text(entry) }}
{%- elif entry['type'] == 'icon' -%}
{{ render_icon(entry) }}
{%- elif entry['type'] == 'url' -%}
{{ render_url(entry) }}
{%- else -%}
{{ raise('Unknown entry type.') }}
{{ raise('Unknown entry type: {}.'.format(entry)) }}
{%- endif -%}
{%- endmacro -%}
{# Renders a list of enumeration entries (either links or text) #}
{%- macro render_enumeration(enumeration) -%}
{%- set comma = joiner(", ") -%}
{{ render_text(enumeration['name']) }}: {% for entry in enumeration['entries'] -%}{{ comma() }}{{ render_enumeration_entry(entry) }}{%- endfor -%}
{%- set divider = joiner(enumeration['divider']) -%}
{{ render_text(enumeration['name']) }}: {% for entry in enumeration['entries'] -%}{{ divider() }}{{ render_element(entry) }}{%- endfor -%}
{%- endmacro -%}