From cfe6c0f564990415121a1b995374d28efb6bb5ff Mon Sep 17 00:00:00 2001 From: Deimos Date: Tue, 16 Jul 2019 18:54:33 -0600 Subject: [PATCH] Fix pluralization for og:description Added a new "pluralize" macro to make this easier, so I'll go back and implement this in the other places as well. --- tildes/tildes/templates/macros/utils.jinja2 | 15 +++++++++++++++ tildes/tildes/templates/topic.jinja2 | 3 ++- 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 tildes/tildes/templates/macros/utils.jinja2 diff --git a/tildes/tildes/templates/macros/utils.jinja2 b/tildes/tildes/templates/macros/utils.jinja2 new file mode 100644 index 0000000..7aafd55 --- /dev/null +++ b/tildes/tildes/templates/macros/utils.jinja2 @@ -0,0 +1,15 @@ +{# Copyright (c) 2019 Tildes contributors #} +{# SPDX-License-Identifier: AGPL-3.0-or-later #} + +{% macro pluralize(counter, base_word, plural_word=None) %} + {% if not plural_word %} + {% set plural_word = base_word~"s" %} + {% endif %} + + {%- trans counter=counter -%} + {{ counter }} {{ base_word }} + {%- pluralize -%} + {{ counter }} {{ plural_word }} + {%- endtrans %} +{% endmacro %} + diff --git a/tildes/tildes/templates/topic.jinja2 b/tildes/tildes/templates/topic.jinja2 index bdf338b..90d1970 100644 --- a/tildes/tildes/templates/topic.jinja2 +++ b/tildes/tildes/templates/topic.jinja2 @@ -9,12 +9,13 @@ {% from 'macros/forms.jinja2' import markdown_textarea %} {% from 'macros/links.jinja2' import group_linked, username_linked %} {% from 'macros/topics.jinja2' import topic_voting with context %} +{% from 'macros/utils.jinja2' import pluralize %} {% block title %}{{ topic.title }} - ~{{ topic.group.path }}{% endblock %} {% block meta_og_tags %} - + {% endblock %} {% block templates %}