feat: user handlebars as template engine for mailing & remove ejs

This commit is contained in:
abdou6666
2025-03-13 16:33:13 +01:00
committed by Mohamed Marrouchi
parent 6f02cf1443
commit ba4305a5c2
7 changed files with 77 additions and 54 deletions

View File

@@ -71,7 +71,15 @@ const i18nOptions: I18nOptions = {
debug: false,
}),
template: {
adapter: new MjmlAdapter('ejs', { inlineCssEnabled: false }),
adapter: new MjmlAdapter(
'handlebars',
{
inlineCssEnabled: false,
},
{
handlebar: {},
},
),
dir: path.join(process.cwd(), 'dist', 'templates'),
options: {
context: {

View File

@@ -2,34 +2,38 @@
<mj-body>
<mj-section>
<mj-column>
<mj-image width="186px" src="https://hexabot.ai/assets/images/logo.png"></mj-image>
<mj-image
width="186px"
src="https://hexabot.ai/assets/images/logo.png"
></mj-image>
<mj-divider border-color="#000"></mj-divider>
<mj-text font-size="16px" color="#000" font-family="helvetica"
><%= t('hi') %> <%= first_name %>,</mj-text
>
<mj-text font-size="16px" color="#000" font-family="helvetica"
><%= t('account_successfully_created_confirm_password') %></mj-text
>
<mj-text font-size="16px" color="#000" font-family="helvetica">
{{t 'hi'}} {{first_name}},
</mj-text>
<mj-text font-size="16px" color="#000" font-family="helvetica">
{{t 'account_successfully_created_confirm_password'}}
</mj-text>
<mj-text font-size="16px" color="#000" font-family="helvetica"
><%= t('confirm_account') %></mj-text
>
<mj-text font-size="16px" color="#000" font-family="helvetica">
{{t 'confirm_account'}}
</mj-text>
<mj-button
href="<%= this.appUrl %>/login/<%= token %>"
href="{{appUrl}}/login/{{token}}"
font-size="16px"
background-color="#000"
><%= t('confirm') %></mj-button
>
{{t 'confirm'}}
</mj-button>
</mj-column>
</mj-section>
<mj-section>
<mj-column>
<mj-text font-size="16px" color="#000" font-family="helvetica"
><%= t('best_regards') %></mj-text
>
<mj-text font-size="16px" color="#000" font-family="helvetica"
><%= this.appName %></mj-text
>
<mj-text font-size="16px" color="#000" font-family="helvetica">
{{t 'best_regards'}}
</mj-text>
<mj-text font-size="16px" color="#000" font-family="helvetica">
{{appName}}
</mj-text>
</mj-column>
</mj-section>
</mj-body>

View File

@@ -2,36 +2,39 @@
<mj-body>
<mj-section>
<mj-column>
<mj-image width="186px" src="https://hexabot.ai/assets/images/logo.png"></mj-image>
<mj-image
width="186px"
src="https://hexabot.ai/assets/images/logo.png"
></mj-image>
<mj-divider border-color="#000"></mj-divider>
<mj-text font-size="16px" color="#000" font-family="helvetica">
<%= t('welcome') %>,
{{t 'welcome'}}
</mj-text>
<mj-text font-size="16px" color="#000" font-family="helvetica">
{{t 'invitation_for_account_creation'}} {{appName}} {{t 'account'}}.
</mj-text>
<mj-text font-size="16px" color="#000" font-family="helvetica"
><%= `${t('invitation_for_account_creation')} ${this.appName}
${t('account')}.` %></mj-text
>
<mj-text font-size="16px" color="#000" font-family="helvetica"
><%= t('create_account') %></mj-text
>{{ t 'create_account'}}</mj-text
>
<mj-button
href="<%= this.appUrl %>/register/<%= token %>"
href="{{appUrl}}/register/{{token}}"
font-size="16px"
background-color="#000"
><%= t('join') %></mj-button
>
{{t 'join'}}</mj-button
>
</mj-column>
</mj-section>
<mj-section>
<mj-column>
<mj-text font-size="16px" color="#000" font-family="helvetica"
><%= t('best_regards') %></mj-text
>
>{{t 'best_regards'}}
</mj-text>
<mj-text font-size="16px" color="#000" font-family="helvetica"
><%= this.appName %></mj-text
>{{this.appName }}</mj-text
>
</mj-column>
</mj-section>

View File

@@ -2,33 +2,37 @@
<mj-body>
<mj-section>
<mj-column>
<mj-image width="186px" src="https://hexabot.ai/assets/images/logo.png"></mj-image>
<mj-image
width="186px"
src="https://hexabot.ai/assets/images/logo.png"
></mj-image>
<mj-divider border-color="#000"></mj-divider>
<mj-text font-size="16px" color="#000" font-family="helvetica"
><%= t('hi') %> <%= first_name %>,</mj-text
>
<mj-text font-size="16px" color="#000" font-family="helvetica"
><%= t('password_reset_request') %></mj-text
>
<mj-text font-size="16px" color="#000" font-family="helvetica"
><%= t('click_to_reset_password') %></mj-text
>
<mj-text font-size="16px" color="#000" font-family="helvetica">
{{t 'hi'}} {{first_name}},
</mj-text>
<mj-text font-size="16px" color="#000" font-family="helvetica">
{{t 'password_reset_request'}}
</mj-text>
<mj-text font-size="16px" color="#000" font-family="helvetica">
{{t 'click_to_reset_password'}}
</mj-text>
<mj-button
href="<%= this.appUrl %>/reset/<%= token %>"
href="{{appUrl}}/reset/{{token}}"
font-size="16px"
background-color="#000"
><%= t('reset') %></mj-button
>
{{t 'reset'}}
</mj-button>
</mj-column>
</mj-section>
<mj-section>
<mj-column>
<mj-text font-size="16px" color="#000" font-family="helvetica"
><%= t('best_regards') %></mj-text
>
<mj-text font-size="16px" color="#000" font-family="helvetica"
><%= this.appName %></mj-text
>
<mj-text font-size="16px" color="#000" font-family="helvetica">
{{t 'best_regards'}}
</mj-text>
<mj-text font-size="16px" color="#000" font-family="helvetica">
{{appName}}
</mj-text>
</mj-column>
</mj-section>
</mj-body>

View File

@@ -1,5 +1,5 @@
/*
* Copyright © 2024 Hexastack. All rights reserved.
* Copyright © 2025 Hexastack. All rights reserved.
*
* Licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms:
* 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission.