-
Notifications
You must be signed in to change notification settings - Fork 968
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Confused about variables #1403
Comments
Oh and I'm also confused by https://dev.mailjet.com/template-language/ vs https://mjml.io/documentation/ |
There is no mention of any templating language in the documentation simply because there isn't any built-in templating language in MJML (and never has been). You're indeed confusing MJML with Mailjet's template language. MJML is a markup language aimed at making it easy to create responsive emails. For templating, you're free to use any template language of your choice, such as Mailjet's template language (which you linked) or https://github.com/pugjs/pug or any other. |
I get it now, but I think that explanation should be in the docs somewhere. I had assumed MJML was a replacement for Handlebars, where it's actually more of a replacement for HTML; meaning you still need Handlebars or an equivalent to generate it. Maybe it's just me but that wasn't obvious at all at first. |
@SachaG : Thanks for your question. I'm confused as well |
But it just makes a lot of sense to provide templating feature in-the-box. Not having template support just makes the whole process redundantly complicated.
Thoughts? :) |
Everything could be automated or integrated in any nodeJS project. We even have browser build now so any templating lang should be easy to plug. There's a detailed issue where we explain why we won't do this here : #1630 |
If you're just looking to interpolate variables, it's pretty simple without any additional libraries. Consider this template:
A function to load the requested template and interpolate:
Usage:
|
Isn't it easier to use something like lodash's How about |
Indeed, it's easier to use |
I'm sure this is a question that gets asked all the time, but I wanted to report my confusion about how MJML handles variables, if at all.
Looking at https://mjml.io/documentation/ I can't see any technique to interpolate variables similar to Handlebars'
{{ foo }}
or JSX'{ bar }
.On the other hand this post from just a few months ago mentions a
{% set gender = var:user.gender %}
syntaxIs that deprecated? If so how do you do something a simple as showing a user's name? (such as the "Hello, Helen" heading from the tutorial).
I feel like even if MJML doesn't support variables anymore, the documentation should include a section about workarounds, because this is going to be one of the first questions anybody new to the library has.
The text was updated successfully, but these errors were encountered: