From eb008fc864dfb18aef408b2afe9c752f5acbd330 Mon Sep 17 00:00:00 2001 From: Vishnu KS Date: Fri, 23 Oct 2020 19:00:13 +0530 Subject: [PATCH] emails: Use macros for email tags in invitation email. --- scripts/setup/inline_email_css.py | 2 +- templates/zerver/emails/email_base_default.source.html | 1 + templates/zerver/emails/invitation.source.html | 5 +++-- templates/zerver/emails/macros.source.html | 7 +++++++ 4 files changed, 12 insertions(+), 3 deletions(-) create mode 100644 templates/zerver/emails/macros.source.html diff --git a/scripts/setup/inline_email_css.py b/scripts/setup/inline_email_css.py index 418ff150f4..c5bfb6c712 100755 --- a/scripts/setup/inline_email_css.py +++ b/scripts/setup/inline_email_css.py @@ -50,7 +50,7 @@ def inline_template(template_source_name: str) -> None: # template, since we'll end up with 2 copipes of those tags. # Thus, we strip this stuff out if the template extends # another template. - if template_name != 'email_base_default': + if template_name not in ['email_base_default', 'macros']: output = strip_unnecesary_tags(output) if ('zerver/emails/compiled/email_base_default.html' in output or diff --git a/templates/zerver/emails/email_base_default.source.html b/templates/zerver/emails/email_base_default.source.html index a3f0a45d70..b79eaf8806 100644 --- a/templates/zerver/emails/email_base_default.source.html +++ b/templates/zerver/emails/email_base_default.source.html @@ -1,3 +1,4 @@ +{% import 'zerver/emails/compiled/macros.html' as macros %} diff --git a/templates/zerver/emails/invitation.source.html b/templates/zerver/emails/invitation.source.html index 158bec2b66..cb3a54284d 100644 --- a/templates/zerver/emails/invitation.source.html +++ b/templates/zerver/emails/invitation.source.html @@ -5,16 +5,17 @@ {% endblock %} {% block content %} +

{{ _("Hi there,") }}

- {% trans %}{{ referrer_full_name }} ({{ referrer_email }}) wants you to join them on Zulip — the team communication tool designed for productivity.{% endtrans %} + {% trans referrer_name=macros.referrer_email_tag(referrer_email, referrer_full_name) %}{{ referrer_name }} wants you to join them on Zulip — the team communication tool designed for productivity.{% endtrans %}

{{ _("To get started, click the button below.") }} {{ _("Complete registration") }}

- {% trans %}Contact us any time at {{ support_email }} if you run into trouble, have any feedback, or just want to chat!{% endtrans %} + {% trans support_email=macros.email_tag(support_email) %}Contact us any time at {{ support_email }} if you run into trouble, have any feedback, or just want to chat!{% endtrans %}

{% endblock %} diff --git a/templates/zerver/emails/macros.source.html b/templates/zerver/emails/macros.source.html new file mode 100644 index 0000000000..7859d6563a --- /dev/null +++ b/templates/zerver/emails/macros.source.html @@ -0,0 +1,7 @@ +{% macro email_tag(email, text) -%} + {{ text | default(email) }} +{%- endmacro %} + +{% macro referrer_email_tag(referrer_email, referrer_name) -%} + {{ referrer_name }} ({{ referrer_email }}) +{%- endmacro %}