[GH-ISSUE #174] Support for conditional and loop templating in render function #60

Closed
opened 2026-03-01 14:39:48 +03:00 by kerem · 4 comments
Owner

Originally created by @Ayo-Awe on GitHub (Apr 4, 2025).
Original GitHub issue: https://github.com/arikchakma/maily.to/issues/174

Hey @arikchakma, great work on the library!

I have a quick question.
I noticed that when using the render function, variables are replaced with placeholders like {{variableName}}, which is really useful for interoperability with external templating engines. However, I noticed that the same doesn’t apply to conditionals and loops.

It would be really useful if those could also be replaced with their templating equivalents—such as Handlebars' #if and #each.

For example:

{{#if author}}
  <h1>{{firstName}} {{lastName}}</h1>
{{/if}}

{{#each people}}
  <li>{{this}}</li>
{{/each}}

Would love to hear your thoughts!

Originally created by @Ayo-Awe on GitHub (Apr 4, 2025). Original GitHub issue: https://github.com/arikchakma/maily.to/issues/174 Hey @arikchakma, great work on the library! I have a quick question. I noticed that when using the `render` function, variables are replaced with placeholders like `{{variableName}}`, which is really useful for interoperability with external templating engines. However, I noticed that the same doesn’t apply to conditionals and loops. It would be really useful if those could also be replaced with their templating equivalents—such as Handlebars' [#if](https://handlebarsjs.com/guide/builtin-helpers.html#if) and [#each](https://handlebarsjs.com/guide/builtin-helpers.html#each). For example: ```handlebars {{#if author}} <h1>{{firstName}} {{lastName}}</h1> {{/if}} {{#each people}} <li>{{this}}</li> {{/each}} ``` Would love to hear your thoughts!
kerem closed this issue 2026-03-01 14:39:48 +03:00
Author
Owner

@arikchakma commented on GitHub (Apr 4, 2025):

Currently, we don't support that because we handle the replacement of the loop and the conditional. Kinda we are using that as a replacement of a templating engine. But it should be easy to add.

<!-- gh-comment-id:2778769644 --> @arikchakma commented on GitHub (Apr 4, 2025): Currently, we don't support that because we handle the replacement of the `loop` and the `conditional`. Kinda we are using that as a replacement of a templating engine. But it should be easy to add.
Author
Owner

@Ayo-Awe commented on GitHub (Apr 4, 2025):

Oh, okay. That makes sense.

Unfortunately, my use case requires exporting the templates for use in a non-Node runtime.
But I'll give it a shot on my end, and let you know how it goes

<!-- gh-comment-id:2779431320 --> @Ayo-Awe commented on GitHub (Apr 4, 2025): Oh, okay. That makes sense. Unfortunately, my use case requires exporting the templates for use in a non-Node runtime. But I'll give it a shot on my end, and let you know how it goes
Author
Owner

@arikchakma commented on GitHub (Apr 5, 2025):

Did you find any solutions for this one? It should be simple, imo.

<!-- gh-comment-id:2780673467 --> @arikchakma commented on GitHub (Apr 5, 2025): Did you find any solutions for this one? It should be simple, imo.
Author
Owner

@Ayo-Awe commented on GitHub (Apr 5, 2025):

I still taking a look, but the approach I'm considering is customizing the rendered html of the repeat node.
I wouldn't mind some guidance if you have an idea of a way to go about it

<!-- gh-comment-id:2780915635 --> @Ayo-Awe commented on GitHub (Apr 5, 2025): I still taking a look, but the approach I'm considering is customizing the rendered html of the repeat node. I wouldn't mind some guidance if you have an idea of a way to go about it
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/maily.to#60
No description provided.