chiark / gitweb /
pelican-theme: wrap page/article content in blocks.
authorLukas Pirl <git@lukas-pirl.de>
Wed, 13 May 2020 08:57:48 +0000 (10:57 +0200)
committerVladimír Vondruš <mosra@centrum.cz>
Thu, 14 May 2020 12:14:44 +0000 (14:14 +0200)
For easier extension/customization/overriding of templates.

pelican-theme/templates/article.html
pelican-theme/templates/page.html
pelican-theme/templates/passthrough.html

index 7b09f18b0997e53e1fc9468dbcaa957cdc11bd77..611fe9c815d7f88a99fe11a0bebb53e8b21c16c4 100644 (file)
@@ -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 %}
 <!-- content -->
-{{ article.content|trim }}
+{{ article_content_block() }}
 <!-- /content -->
           {% if article.category.badge or (article.author and article.author.badge) %}
           {{ badges()|rtrim|indent(10) }}
       {% endif %}
       {% if article.content %}
 <!-- content -->
-{{ article.content|trim }}
+{{ article_content_block() }}
 <!-- /content -->
       {% endif %}
       {% if article.category.badge or (article.author and article.author.badge) %}
index 2328e10160fe2925310d447e855ebe3bf5549089..a41182ac0aeace2fb47d4daf17787ca77882cd25 100644 (file)
         {% endif %}
         {% if page.content %}
 <!-- content -->
-{{ page.content|trim }}
+{% block page_content -%}
+  {{- page.content|trim }}
+{% endblock %}
 <!-- /content -->
         {% endif %}
       </div>
index bdf92b773fccf2980531a680251803025de7242e..7570ef954592fa296427a07ab1504339fef4670b 100644 (file)
@@ -21,6 +21,8 @@
   {% endif %}
 </head>
 <body>
-{{- page.content -}}
+{%- block page_content -%}
+  {{- page.content -}}
+{%- endblock -%}
 </body>
 </html>