Coder Social home page Coder Social logo

Comments (6)

boardfish avatar boardfish commented on September 26, 2024 1

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.

sighmon avatar sighmon commented on September 26, 2024

@boardfish What happens if you wrap them in an <mj-raw> tag?

from mjml-rails.

boardfish avatar boardfish commented on September 26, 2024

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.

sighmon avatar sighmon commented on September 26, 2024

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

boardfish avatar boardfish commented on September 26, 2024

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.

boardfish avatar boardfish commented on September 26, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.