![]() MJML is such a fantastic tool to build responsive email newsletters without the hassle and I am super happy to see a proper and simple Rails integration. That way, you can use your compiled code as an editable BE template and more easily make updates to your template without worrying about redoing your BE tags each time. the formats property has to be set to (not ). If you use MJML to develop your email templates, this guide will show you how you can add Blocks Edit editable tags to your template, directly within the MJML code.the leading underscore is not necessary.For instance, each section of the newsletter could live in its own file.Ĭonsider the following header (taken from MJML documentation): ![]() When the mail gets a bit long or repetitive, it might be interesting to leverage the power of ERB to have separate files, and render them inside the main template. app/mailers/foobar_mailer.rb class FoobarMailer Hello Let’s create a very simple email through MJML to illustrate this article.įirst thing, in app/mailers, we create a foobar_mailer.rb file: #. #Mjml code for a line installOr if you already use some Node.js modules, you could also just add it to your package.json file: npm install -save mjml Building a MJML-powered email You can either install it globally to avoid adding a Node.js dependency to your project: npm install -g mjml Because of this, it needs mjml to be installed independently. The thing is, this gem is basically just a wrapper around the mjml npm package. While MJML is fairly recent, I was pleased to see there already is a fresh gem to plug it into Rails, called mjml-rails.įirst step would be to add it to the Gemfile. Therefore, I needed a way to integrate MJML in the Rails pipeline to be able to produce proper responsive emails based on dynamic data. Setting up MJML in RailsĪmaphiko is a Rails app. MJML comes with about 20 components to build simple newsletters (texts, images, links, buttons, columns, tables, etc.) and can be extended by leveraging the power of React for advanced usage. ![]() Practically speaking, MJML is a markup language built on React that produces email-compliant (whatever that means) markup once compiled. MJML introduces itself as “the responsive email framework”. And since I won’t code email, at least not in this life, I had to find a workaround. Recently, I had to implement an email for the Amaphiko project. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |