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
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ repos:
exclude: |
(?x)^(
frontend/src/client/.*|
backend/app/email-templates/build/.*
backend/app/email-templates/.*
)$
- id: trailing-whitespace
exclude: ^frontend/src/client/.*
Expand Down
1 change: 0 additions & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"charliermarsh.ruff",
"docker.docker",
"github.vscode-github-actions",
"mjmlio.vscode-mjml",
"ms-playwright.playwright",
"ms-python.python",
"tombi-toml.tombi"
Expand Down
18 changes: 15 additions & 3 deletions backend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,20 @@ If you don't want to start with the default models and want to remove them / mod

## Email Templates

The email templates are in `./backend/app/email-templates/`. Here, there are two directories: `build` and `src`. The `src` directory contains the source files that are used to build the final email templates. The `build` directory contains the final email templates that are used by the application.
The email templates are written with [React Email](https://react.email) in `./packages/react-email/`. The `emails` directory holds one component per email and the `ui` directory holds the shared components (layout, heading, button, link, callout).

Before continuing, ensure you have the [MJML extension](https://github.com/mjmlio/vscode-mjml) installed in your VS Code.
The rendered HTML in `./backend/app/email-templates/` is generated from those components, it is what the application sends, and it shouldn't be edited by hand.

Once you have the MJML extension installed, you can create a new email template in the `src` directory. After creating the new email template and with the `.mjml` file open in your editor, open the command palette with `Ctrl+Shift+P` and search for `MJML: Export to HTML`. This will convert the `.mjml` file to a `.html` file and now you can save it in the build directory.
To preview the emails while editing them, start the dev server from the root of the project:

```console
$ bun run email:dev
```

Values coming from the backend are declared as Jinja placeholders in the component props, for example `username = "{{ username }}"`. The context for each email is built in `generate_*_email()` in `./backend/app/utils.py`, so a new placeholder needs to be added there too.

Once you are done, regenerate the templates used by the application:

```console
$ bun run email:export
```
25 changes: 0 additions & 25 deletions backend/app/email-templates/build/new_account.html

This file was deleted.

25 changes: 0 additions & 25 deletions backend/app/email-templates/build/reset_password.html

This file was deleted.

25 changes: 0 additions & 25 deletions backend/app/email-templates/build/test_email.html

This file was deleted.

Loading