{%- import 'macros/getters.html' as get with context -%}
{%- import 'macros/cards.html' as cards with context -%}
{%- import 'macros/content_renderer.html' as content_renderer with context -%}
{%- macro softbreak_span(content) -%}
{%- set contentsplit = content.split('')-%}
{%- for s in contentsplit -%}
{%- if not loop.first -%}
{%- endif -%}
{{ s|e }}
{%- endfor -%}
{%- endmacro -%}
{%- macro section_news(s, lang) -%}
{{ cards.cards_from_pages(pages_modified[lang], max=s.num|d(None)) }}
{%- endmacro -%}
{%- macro section_relevant(s, lang) -%}
{{ cards.cards_from_pages(relevant_pages[lang], max=s.num|d(None)) }}
{%- endmacro -%}
{%- macro section_iframe(s, lang) -%}
{%- endmacro -%}
{%- macro section_tag(s, lang) -%}
{%- if s.title is not defined -%}
{{ softbreak_span(s.tag.title) }}
{%- endif -%}
{{ cards.cards_from_pages(s.tag.pages, lang, max=s.num|d(None)) }}
{%- if s.tag.page -%}
{{ content_renderer.render_content(s.tag.page.content, lang) }}
{%- endif -%}
{%- endmacro -%}
{%- macro section(s, lang) -%}
{%- if s.title is defined -%}
{{ softbreak_span(s.title[lang]) }}
{%- endif -%}
{%- if s.type == "news" -%}
{{ section_news(s, lang) }}
{%- elif s.type == "iframe" -%}
{{ section_iframe(s, lang) }}
{%- elif s.type == "tag" -%}
{{ section_tag(s, lang) }}
{%- elif s.type == "relevant" -%}
{{ section_relevant(s, lang) }}
{%- else -%}
ERROR: render.section: Unknown section type: {{ s.type|e }}
{%- endif -%}
{%- endmacro -%}
{%- macro sections(sl, lang) -%}
{%- for s in sl -%}
{%- endfor -%}
{%- endmacro -%}