
#MJML VARIABLES CODE#
The combination of mj-var and mj-env provide an unopinionated solution to writing arbitrary templated code in MJML. The code inside the DEV tag would show for local development, and PROD would show for the final build. The mj-var tag solves the problem of parsing and generating templated code, but doesn't solve the issue of rendering during development.įor that, I propose adding an mj-env tag that only renders itself if the associated environment variable is set during the build step.Įxample variable declaration with environment conditionals:
#MJML VARIABLES FULL#
The compiler should emit a warning for undeclared variable usage with the ability to opt-into a full error. These variables should also be escapable via a \%backslash%.īy default, %variables% that have not been declared by an mj-var tag should be treated as if they were escaped for backwards compatibility with with templates that happen to have variable-looking code in them. One is a partial fix that ensures MJML will always be able to parse and generate templated code, and the other is a fix that allows dummy data during development.Īdd an mj-var tag that allows the user to declare template %variables% which are recognized by the MJML parser and guaranteed not to be altered by any MJML processing steps. I have two solutions I'd like to propose. This is solvable with custom processing pipelines, but that's beyond the ability of many designers to setup themselves, and MJML doesn't have an officially supported solution that designers can leverage. While MJML's mj-raw tag works nicely inside HTML blocks, it doesn't help us with inserting template code into HTML attributes or CSS blocks.Īdditionally, a pre-processing step is necessary if you want to use dummy data while developing, otherwise the user's raw template tags are rendered in the browser, ranging from an 'ugly' to a 'broken' appearance. Problem 3 - Quotation marks can cause issues with the generated HTML.

Problem 2 - The CSS processing step sometimes alters the template code, potentially enough for the ESP to not render it properly. Problem 1 - It breaks syntax highlighting and throws editor errors. When I'm writing email templates, they usually require dynamic values to be inserted via ESP template code, but attempting to write naive templated MJML results in a variety of errors.


Is your feature request related to a problem? Please describe.
