From a4d77926b6f7a011bcd35408a0471e24efd80432 Mon Sep 17 00:00:00 2001
From: robrobinbin <>
Date: Tue, 12 Jan 2021 23:34:16 +0100
Subject: [PATCH] Rich flairs
---
templates/post.html | 12 +++++++++---
templates/search.html | 8 ++++++--
templates/subreddit.html | 4 +++-
templates/user.html | 6 ++++--
templates/utils.html | 6 +-----
5 files changed, 23 insertions(+), 13 deletions(-)
diff --git a/templates/post.html b/templates/post.html
index 944c4f3..e9c7a5b 100644
--- a/templates/post.html
+++ b/templates/post.html
@@ -22,7 +22,9 @@
- {% call utils::render_flair(post.flair) %}
+ {% if post.flair.flair_parts.len() > 0 %}
+ {% call utils::render_flair(post.flair.flair_parts) %}
+ {% endif %}
{{ post.title }}
diff --git a/templates/subreddit.html b/templates/subreddit.html
index abfa12b..734d295 100644
--- a/templates/subreddit.html
+++ b/templates/subreddit.html
@@ -46,7 +46,9 @@
- {% call utils::render_flair(post.flair) %}
+ {% if post.flair.flair_parts.len() > 0 %}
+ {% call utils::render_flair(post.flair.flair_parts) %}
+ {% endif %}
{{ post.title }}
diff --git a/templates/user.html b/templates/user.html
index 6725894..070e253 100644
--- a/templates/user.html
+++ b/templates/user.html
@@ -32,7 +32,9 @@
@@ -40,7 +42,7 @@
{% if post.flair.background_color == "Comment" %}
{% else if post.flair.background_color == "" %}
{% else %}
- {% call utils::render_flair(post.flair) %}
+
{% call utils::render_flair(post.flair.flair_parts) %}
{% endif %}
{{ post.title }}
diff --git a/templates/utils.html b/templates/utils.html
index 0a0b726..5665246 100644
--- a/templates/utils.html
+++ b/templates/utils.html
@@ -28,15 +28,11 @@
{%- endmacro %}
{% macro render_flair(flair) -%}
-{% if flair.flair_parts.len() > 0 %}
-
-{% for flair_part in flair.flair_parts %}
+{% for flair_part in flair %}
{% if flair_part.flair_part_type == "emoji" %}
{% else if flair_part.flair_part_type == "text" %}
{{ flair_part.value }}
{% endif %}
{% endfor %}
-
-{% endif %}
{%- endmacro %}
u/{{ item.author }} - {% call utils::render_flair(item.flair) %} + {% if item.flair.flair_parts.len() > 0 %} + {% call utils::render_flair(item.flair.flair_parts) %} + {% endif %} {{ item.time }}
{{ item.body }}
@@ -48,13 +50,17 @@ r/{{ post.community }} • u/{{ post.author }} - {% call utils::render_flair(post.author_flair) %} + {% if post.author_flair.flair_parts.len() > 0 %} + {% call utils::render_flair(post.author_flair.flair_parts) %} + {% endif %} • {{ post.time }}