Comments (6)
Here's that regex: /({[{%](?:\s\w+\s*)?)\w{2,}:(\w+)(?::[\w"]+)?(.*[%}]})/
You'll need to run it multiple times:
loop { break unless template_content.gsub!(regex) }
from mjml-rails.
@boardfish What happens if you wrap them in an <mj-raw>
tag?
from mjml-rails.
If I understood you correctly, using <mj-raw>{{var:name}}</mj-raw>
might change things. Unfortunately, there was no change in output. Thanks for the quick response!
from mjml-rails.
@boardfish And if you wrap them: <mj-text>{{var:name}}</mj-text>
does that work any better?
Perhaps I'm missing the problem... you might have to describe it a little clearer for me sorry - it's been a while since I've been back into this project.
from mjml-rails.
I'll give that a try tomorrow.
The problem I'm facing is that I want to use Mailjet's templating syntax (e.g. {{var:name}}
) to inject data into the rendered MJML. I'm aware this gem has support for ERB templating syntax (<%= @name %>
) inside MJML, but native support for Mailjet's syntax would be really helpful for my use case. Ideally, {{var:name}}
would do the same as <%= @name %>
and add the value of @name
to the output buffer .
It seems Mailjet's syntax for MJML also includes conditionals ({% if something === "true" %}
) among other things, and it's kind of adjacent to Handlebars/Mustache templates.
I might have an alternative solution to my base problem, which is to deal with Mailjet templates locally and render them via Action Mailer. I'll investigate that side of things further - hopefully it renders this issue moot.
from mjml-rails.
Closing this issue because my alternate solution — passing Mailjet's HTMLContent
through a gnarly regex and processing it with Mustache — appears to have worked. There may be a good reason for this gem to support Mailjet's Mustache-esque tags, but I figure another issue should be opened if that ever becomes the case.
from mjml-rails.
Related Issues (20)
- Update GitHub actions
- [Bug] Does not find MJML executable with npm 9+ (yarn 2+ uses npm discovery) HOT 2
- Slow to render layout, and too much object(memory) Allocations HOT 1
- Prevents booting when `which` is missing HOT 8
- Can i override a layout? HOT 1
- How to custom template path? HOT 1
- Add config option for fonts HOT 1
- Fix test pipeline for Ruby 2.7
- Warning about MJML missing when using MRML HOT 5
- Database template support HOT 1
- What node packages need to make it working properly? HOT 1
- unable to load included template when using MRML HOT 3
- Slow boot time due to version check HOT 1
- Fix tests
- RuboCop? HOT 2
- `Mjml::Parser#render` suppresses errors in case of Tempfile exceptions HOT 2
- Exit code in case of an error when calling the mjml binary HOT 3
- SIGKILL (signal 9) on many concurrent emails HOT 3
- How to use this library to generate a string of raw html? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mjml-rails.