Skip to content
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

mj-raw modifies the raw value #485

Closed
brianharwell opened this issue Dec 27, 2016 · 6 comments
Closed

mj-raw modifies the raw value #485

brianharwell opened this issue Dec 27, 2016 · 6 comments

Comments

@brianharwell
Copy link

I am trying to incorporate mjml into my application and I'm trying to use razor or t4 for a templating engine. The issue I am having is that the mjml parser doesn't leave the contents of mj-raw alone. Instead it tries to make it "right".

Take for example <#@ #> This is perfectly valid T4 code but mjml converts it to <#@ #=""></#@>

I think whatever is inserted in the mj-raw tags should be completely ignored by the mjml parser.

@rogierslag
Copy link
Contributor

This is a probably problem with the current parser system. You might be better off running the template engine on the mjml code before handing it over to mjml.

@brianharwell
Copy link
Author

brianharwell commented Dec 27, 2016 via email

@ngarnier
Copy link
Member

ngarnier commented Jan 4, 2017

Hey @brianharwell, @rogierslag is perfectly right, this is an issue with our parser when < and > are encountered. I don't have any experience with .Net so I won't be able to help on templating in .NET. However, I can suggest you a workaround: you can replace the < and > characters by their HTML entities. Example:
<mj-raw>&lt;#@ #&gt;</mj-raw>

Would that work until we implement a new parser?

@brianharwell
Copy link
Author

I'll give it a shot!

@ngarnier ngarnier added the MJML 4 label Mar 1, 2017
@ngarnier ngarnier reopened this Apr 24, 2017
@ngarnier ngarnier added this to Near Term in MJML Roadmap Oct 27, 2017
@ngarnier ngarnier moved this from Near Term to Soon to be released in MJML Roadmap Jan 16, 2018
@ngarnier
Copy link
Member

It's fixed in the latest MJML 4 beta! Install with npm install mjml@next

@ngarnier ngarnier added this to the 4.0.0 milestone Jan 25, 2018
@ngarnier ngarnier moved this from Soon to be released to Released in MJML Roadmap Feb 7, 2018
@julius-spudvilas
Copy link

julius-spudvilas commented May 4, 2020

Dont think that fix for this work...
<mj-raw>var isNewInSale = property.DaysInSale <= 15;</mj-raw> --- Will break PARSER
<mj-raw>var isNewInSale = 15 >= property.DaysInSale;</mj-raw> --- Will work as expected

So seams like < symbol breaking parser while > is working fine

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
MJML Roadmap
  
Released
Development

No branches or pull requests

4 participants