From 1b032f98ff3563a41d2af234ba7ca9e86c0aee99 Mon Sep 17 00:00:00 2001 From: Evie Viau Date: Tue, 7 Feb 2023 03:37:29 -0800 Subject: [PATCH] Split block resolver into its own file --- templates/page.html | 16 ++-------------- templates/post.html | 15 +-------------- templates/resolve_content.html | 14 ++++++++++++++ 3 files changed, 17 insertions(+), 28 deletions(-) create mode 100644 templates/resolve_content.html diff --git a/templates/page.html b/templates/page.html index 3dd1cc4..c7c8157 100644 --- a/templates/page.html +++ b/templates/page.html @@ -23,19 +23,7 @@ {% endif -%} {% for content_block in content_blocks %} - {% match content_block %} - {% when BlockTypes::HR %} -
- {% when BlockTypes::PARAGRAPH { text } %} -

{{ text }}

- {% when BlockTypes::MARKDOWN { content } %} - {{ content|markdown }} - {% when BlockTypes::HTML { content } %} - {{ content|safe }} - {% when BlockTypes::HEADER { text, size } %} - {{text}} - {% else %} - UNSUPPORTED block type here! - {% endmatch %} + {% include "resolve_content.html" %} {% endfor %} + {% endblock %} diff --git a/templates/post.html b/templates/post.html index ed54c66..b4a913d 100644 --- a/templates/post.html +++ b/templates/post.html @@ -34,20 +34,7 @@
{% for content_block in content_blocks %} - {% match content_block %} - {% when BlockTypes::HR %} -
- {% when BlockTypes::PARAGRAPH { text } %} -

{{ text }}

- {% when BlockTypes::MARKDOWN { content } %} - {{ content|markdown }} - {% when BlockTypes::HTML { content } %} - {{ content|safe }} - {% when BlockTypes::HEADER { text, size } %} - {{text}} - {% else %} - UNSUPPORTED block type here! - {% endmatch %} + {% include "resolve_content.html" %} {% endfor %}
diff --git a/templates/resolve_content.html b/templates/resolve_content.html new file mode 100644 index 0000000..fad8a80 --- /dev/null +++ b/templates/resolve_content.html @@ -0,0 +1,14 @@ +{% match content_block %} + {% when BlockTypes::HR %} +
+ {% when BlockTypes::PARAGRAPH { text } %} +

{{ text }}

+ {% when BlockTypes::MARKDOWN { content } %} + {{ content|markdown }} + {% when BlockTypes::HTML { content } %} + {{ content|safe }} + {% when BlockTypes::HEADER { text, size } %} + {{text}} + {% else %} + UNSUPPORTED block type here! +{% endmatch %}