From 345a0d942fd436d24f15892d581140f1efffaedc Mon Sep 17 00:00:00 2001 From: m Date: Sat, 14 Mar 2026 12:36:13 +0100 Subject: [PATCH] post renderer --- templates/components/post_renderer.html | 9 +++++++++ templates/post_detail.html | 8 ++++---- 2 files changed, 13 insertions(+), 4 deletions(-) create mode 100644 templates/components/post_renderer.html diff --git a/templates/components/post_renderer.html b/templates/components/post_renderer.html new file mode 100644 index 0000000..eb9ed22 --- /dev/null +++ b/templates/components/post_renderer.html @@ -0,0 +1,9 @@ +{% macro render_post(post) %} +
+ {% if post.template %} {% include post.template %} {% endif %} {{ post.content + | safe }} +
+ +
+ +{% endmacro %} diff --git a/templates/post_detail.html b/templates/post_detail.html index f1edf9b..df855ed 100644 --- a/templates/post_detail.html +++ b/templates/post_detail.html @@ -1,5 +1,7 @@ {% extends "base.html" %} {% block title %}{{ post.title }} - Simple Blog -Template{% endblock %} {% block content %} +Template{% endblock %} {% block content %} {% from +"components/post_renderer.html" import render_post %} +

{{ post.title }}

@@ -9,7 +11,7 @@ Template{% endblock %} {% block content %} Posted on {{ post.date }}


- {% if post.id == 8 %} + {{ render_post(post, post.displayall) }} {% if post.id == 8 %}

@@ -19,8 +21,6 @@ Template{% endblock %} {% block content %}
{{ post.content | safe }}
- {% if post.template} {% include post.template %} {% endif %} - ← Back to Posts