question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Confused about variables

See original GitHub issue

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 %} syntax

Is 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.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:14
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

75reactions
SachaGcommented, Oct 29, 2018

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.

2reactions
softmarshmallowcommented, May 26, 2021

But it just makes a lot of sense to provide templating feature in-the-box. The whole project is designed for developer usage, so i think this is essential to have.

Not having template support just makes the whole process redundantly complicated.

  1. create mjml file
  2. create template definitions
  3. custom scripts for replacing or using handlebar for static mjml file
  4. convert mjml file to html
  5. and on

Thoughts? 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Confused about variables - calculus - Math Stack Exchange
Well, the underlying concept is simple. We take a certain point (x0,y0) lying on the given curve. At this point, slope of tangent...
Read more >
A little confused on variables - Get Help - Codecademy Forums
Hi, I am on this lesson (https://www.codecademy.com/courses/introduction-to-javascript/lessons/variables/exercises/var It says on the hint ...
Read more >
I'm really confused about variables and global variables - Reddit
First, a variable is just a word that holds a value. It saves that information for you to use later. For example, let's...
Read more >
I think there's something I'm confused about with the variables
This for loop (the body of the loop) for (a; a > b; a++). is never executed because in the preceding code a...
Read more >
How to think about instrumental variables when you get ...
How to think about instrumental variables when you get confused ... and so Piero did a more elaborate instrumental variables analysis using ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found