Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions packages/dsw-mailer/dsw/mailer/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,14 @@ def __init__(self, *, message_id: str, subject: str, subject_prefix: bool,
self.parts: list[TemplateDescriptorPart] = []
self.modes: list[str] = []

@property
def subject_template(self) -> str:
# trans block limits use of Jinja, if it looks like a template, then
# handle trans yourselves
if '{{' not in self.subject and '{%' not in self.subject:
return '{% trans %}' + self.subject + '{% endtrans %}'
return self.subject

@staticmethod
def load_from_file(data: dict) -> TemplateDescriptor:
result = TemplateDescriptor(
Expand Down
2 changes: 1 addition & 1 deletion packages/dsw-mailer/dsw/mailer/templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def _load_template(self, path: pathlib.Path,
html_template = None
plain_template = None
subject_template = self._make_str_jinja2(
str_template='{% trans %}' + descriptor.subject + '{% endtrans %}',
str_template=descriptor.subject_template,
)
attachments = []
html_images = []
Expand Down
Loading