diff --git a/templates/components/post_preview.html b/templates/components/post_preview.html new file mode 100644 index 0000000..44530e2 --- /dev/null +++ b/templates/components/post_preview.html @@ -0,0 +1,20 @@ +{% macro render_post(post, expanded=False) %} {% if expanded %} + +
{{ post.content | safe }}
+ +
+ +{% else %} + +
{{ post.content | striptags | truncate(200) }}
+ + + Read More + + +
+ +{% endif %} {% endmacro %} diff --git a/templates/index.html b/templates/index.html index 30b5095..e90807f 100644 --- a/templates/index.html +++ b/templates/index.html @@ -1,5 +1,6 @@ -{% extends "base.html" %} {% block title %}{{blog_title.title}}{% endblock %} {% -block content %} +{% from "components/post_preview.html" import render_post %} {% extends +"base.html" %} {% block title %}{{blog_title.title}}{% endblock %} {% block +content %} @@ -18,22 +19,7 @@ block content %}

Posted on {{ post.date }}

- - {% if post.displayall %} -
{{ post.content | safe }}
-
- - {% else %} -
{{ post.content | striptags | truncate(200) }}
- - Read More -
- - {% endif %} {% endfor %} + {{ render_post(post, post.displayall) }} {% endfor %}