[V4] Can I render Edge tags dynamically? #2293
-
Hello 👋 I want my user to be able to edit email templates on the dashboard and I would like to find a way to do that. I thought about saving the content of the email in a database table and making it available for editing on the dashboard. For example: "mail_templates": [
{
"id": 1,
"content": "<h1>Hi, {{user}}</h1>"
},
{
"id": 2,
"content": "<p>Bye, {{user}}<p>"
}
] However, how could I go about rendering this template dynamically? Would the solution be something like the code below? const edge = require('edge.js');
const data = { user: 'virk' };
const { content } = await TemplateMail.first();
const template = await edge.renderString(content, data);
await Mail.send(template, data); How could I render the content within an Edge layout (using |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
If it is related to using edge directly, then you can do that using the latest edge release. https://github.com/edge-js/edge/releases/tag/v4.0.2. AdonisJS will have this feature in the next release |
Beta Was this translation helpful? Give feedback.
-
@thetutlage is there a way of doing this in AdonisJS in V5 with a syntax like this: await Mail.sendLater((message) => {
message.htmlView('emails/welcome', {
templateText: "Welcome {{ user.fullName }}" // Render params that are inside other params
user: { fullName: 'Some Name' },
url: 'https://your-app.com/verification-url',
})
}) |
Beta Was this translation helpful? Give feedback.
If it is related to using edge directly, then you can do that using the latest edge release. https://github.com/edge-js/edge/releases/tag/v4.0.2. AdonisJS will have this feature in the next release