Skip to content

Conversation

@stefanotroncaro
Copy link
Contributor

@stefanotroncaro stefanotroncaro commented Nov 5, 2025

Create templates submodule

Features

  • jinja2 based rendering
  • mjml rendering via mrml library
  • inheritable BaseTemplate and BaseEmailTemplate pydantic schemas to relate template files and required arguments
  • flexible post rendering pipeline configurable on 3 levels: template definition, render method call, and service instance
  • component based template definition example, defining a theme to follow a design system for template consistency
  • module usage examples

Proof of testing

Sample email

image

Test suite

image

@stefanotroncaro stefanotroncaro marked this pull request as ready for review November 5, 2025 22:28
@stefanotroncaro stefanotroncaro marked this pull request as draft November 6, 2025 15:39
@stefanotroncaro stefanotroncaro marked this pull request as ready for review November 28, 2025 20:29
error_message=f"Sending new user email to user {user.id} failed",
from app.users.schemas.templates import NewUserTemplate

template = NewUserTemplate(name=user.email)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about the template not being inyectable here. Is there a specific reason?
I'm thinking about maybe A/B testing where you want to send 2 different new user emails to users depending on X factor.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I totally agree with you.

I want to add that functionality on a later refactor, to clean up the email service so that it is closed for modification (which it currently is not, as it basically requires a new method for each email type).

I didn't do it here because I didn't want to scope creep this PR. Would you be ok with working on that on a different PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants