diff --git a/theme/templates/macros/renderers.html b/theme/templates/macros/renderers.html new file mode 100644 index 0000000000000000000000000000000000000000..8bc98a9f5865fe7accac05c6610f162f3569a68e --- /dev/null +++ b/theme/templates/macros/renderers.html @@ -0,0 +1,81 @@ +{%- import 'macros/getters.html' as get with context -%} +{%- import 'macros/cards.html' as cards with context -%} + +{%- macro section_news(s) -%} + {{ cards.open() }} + {%- for article in all_articles -%} + {%- if loop.index < s.num -%} + {{ cards.card_from_article_or_page(article) }} + {%- endif -%} + {%- endfor -%} + {{ cards.close() }} +{%- endmacro -%} + +{%- macro section_custom(s) -%} + {{ cards.open() }} + {%- for c in s.content -%} + {{ cards.card(title=c[lang], url=c.url, catcolor=c.color) }} + {%- endfor -%} + {{ cards.close() }} +{%- endmacro -%} + +{%- macro section_iframe(s) -%} + <iframe src="{{ s.url }}"></iframe> +{%- endmacro -%} + +{%- macro section_category(s) -%} + {%- call(nativecat, sccat, catarticles) get.category_by_name(s.category) -%} + {%- if s.title is not defined -%} + <header> + <h2 {% if s.id is defined -%}id="{{ s.id }}"{%- endif %}>{{ sccat[lang]|e }}</h2> + </header> + {%- endif -%} + {{ cards.open() }} + {%- for article in catarticles -%} + {%- if loop.index < s.num -%} + {{ cards.card_from_article_or_page(article) }} + {%- endif -%} + {%- endfor -%} + {{ cards.close() }} + {%- endcall -%} +{%- endmacro -%} + +{%- macro section_tag(s) -%} + {%- call(nativetag, sccat, tagarticles) get.tag_by_name(s.tag) -%} + {%- if s.title is not defined -%} + <header> + <h2 {% if s.id is defined -%}id="{{ s.id }}"{%- endif %}>{{ s.tag|e }}</h2> + </header> + {%- endif -%} + {{ cards.open() }} + {%- for article in tagarticles -%} + {%- if loop.index < s.num -%} + {{ cards.card_from_article_or_page(article) }} + {%- endif -%} + {%- endfor -%} + {{ cards.close() }} + {%- endcall -%} +{%- endmacro -%} + +{%- macro section(s) -%} + {%- if s.title is defined -%} + <header> + <h2 {% if s.id is defined -%}id="{{ s.id }}"{%- endif %}>{{ s.title[lang]|e }}</h2> + </header> + {%- endif -%} + {%- if s.type == "news" -%} + {{ section_news(s) }} + {%- elif s.type == "iframe" -%} + {{ section_iframe(s) }} + {%- elif s.type == "custom" -%} + {{ section_custom(s) }} + {%- elif s.type == "category" -%} + {{ section_category(s) }} + {%- elif s.type == "tag" -%} + {{ section_tag(s) }} + {%- else -%} + <br /> + <strong>ERROR: render.section: Unknown section type: {{ s.type|e }}</strong><br /> + <br /> + {%- endif -%} +{%- endmacro -%}