Generate email .html templates
pnpm generate:emails
- Converts and translates (using
i18n/*.json
) thetemplates/*.template.mjml
files tohtml/*_{lang}.html
andtext-templates/*.template.txt
totxt/*_{lang}.txt
. - Inside the templates,
${key}
is translated using the value of thekey
in the JSON files;{{...}}
and{%...%}
is intended for the Django template engine to interpret when the generated templates are used to render the actual emails, and are left as is by this command. - The text versions of the emails in the
text-templates
directory are translated (to the 'txt' directory) along with the .mjml to .html conversion but do not contain any other syntax that is handled by this command. - For previewing the .mjml templates from which the .html files are generated, install the MJML extension (mjmlio.vscode-mjml), make sure to get the correct one (by MJML).
- To prevent headaches from prettier in formatting of .mjml files include the following in your vscode settings:
"[mjml]": { "editor.defaultFormatter": "mjmlio.vscode-mjml" }
- NOTE: NEVER! EVER! EVER! modify the generated .html/.txt files directly. If changes are required, change the .mjml files in the
templates
and the .txt files in thetext-templates
directory (and/or the translations ini18n/
), and re-generate the .html/.txt files. - See further the documentation in Confluence (Finnish): https://helsinkisolutionoffice.atlassian.net/wiki/spaces/KAN/pages/8178106373/Email-pohjat