From a9853bfde89826a7ff9e1bb21401862bb5613532 Mon Sep 17 00:00:00 2001 From: Lukas Pirl Date: Wed, 13 May 2020 10:57:48 +0200 Subject: [PATCH] pelican-theme: wrap page/article content in blocks. For easier extension/customization/overriding of templates. --- pelican-theme/templates/article.html | 10 ++++++++-- pelican-theme/templates/page.html | 4 +++- pelican-theme/templates/passthrough.html | 4 +++- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/pelican-theme/templates/article.html b/pelican-theme/templates/article.html index 7b09f18b..611fe9c8 100644 --- a/pelican-theme/templates/article.html +++ b/pelican-theme/templates/article.html @@ -1,5 +1,11 @@ {% extends "base_blog.html" %} +{%- macro article_content_block() -%} + {% block article_content -%} + {{- article.content|trim -}} + {%- endblock %} +{%- endmacro -%} + {% block title %}{{ article.title }} | {{ M_BLOG_NAME|e }}{% endblock %} {% block head_links %} @@ -93,7 +99,7 @@ {{ M_ARCHIVED_ARTICLE_BADGE|render_rst|replace('{year}', article.date.year)|indent(8) }} {% endif %} -{{ article.content|trim }} +{{ article_content_block() }} {% if article.category.badge or (article.author and article.author.badge) %} {{ badges()|rtrim|indent(10) }} @@ -121,7 +127,7 @@ {% endif %} {% if article.content %} -{{ article.content|trim }} +{{ article_content_block() }} {% endif %} {% if article.category.badge or (article.author and article.author.badge) %} diff --git a/pelican-theme/templates/page.html b/pelican-theme/templates/page.html index 2328e101..a41182ac 100644 --- a/pelican-theme/templates/page.html +++ b/pelican-theme/templates/page.html @@ -117,7 +117,9 @@ {% endif %} {% if page.content %} -{{ page.content|trim }} +{% block page_content -%} + {{- page.content|trim }} +{% endblock %} {% endif %} diff --git a/pelican-theme/templates/passthrough.html b/pelican-theme/templates/passthrough.html index bdf92b77..7570ef95 100644 --- a/pelican-theme/templates/passthrough.html +++ b/pelican-theme/templates/passthrough.html @@ -21,6 +21,8 @@ {% endif %} -{{- page.content -}} +{%- block page_content -%} + {{- page.content -}} +{%- endblock -%} -- 2.30.2