All Projects → m-basov → mjml-ruby

m-basov / mjml-ruby

Licence: MIT license
✉️ MJML parser and template engine for Ruby

Programming Languages

ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to mjml-ruby

easy-email
React.js Drag-and-Drop Email Editor based on MJML. Transform structured JSON data into major email clients compatible HTML. Written in Typescript and supported both in browser and Node.js.
Stars: ✭ 449 (+816.33%)
Mutual labels:  mjml
catapulte
Rust implementation of catapulte email sender
Stars: ✭ 113 (+130.61%)
Mutual labels:  mjml
mautic-plugin-grapesbuilder
Grapesjs integration for Mautic
Stars: ✭ 23 (-53.06%)
Mutual labels:  mjml
Mjml
MJML: the only framework that makes responsive-email easy
Stars: ✭ 12,880 (+26185.71%)
Mutual labels:  mjml
jolimail
Send nice emails
Stars: ✭ 78 (+59.18%)
Mutual labels:  mjml
laravel-mjml
Laravel MJML offers support for rendering MJML syntax into in-line HTML that can be sent within mails.
Stars: ✭ 26 (-46.94%)
Mutual labels:  mjml
mjml-starter-kit
MJML starter kit, create responsive emails very quickly using MJML and this productive toolchain
Stars: ✭ 35 (-28.57%)
Mutual labels:  mjml
mjml-syntax
Sublime package for the MJML
Stars: ✭ 44 (-10.2%)
Mutual labels:  mjml
mjml-loader
MJML loader for webpack
Stars: ✭ 27 (-44.9%)
Mutual labels:  mjml
mjml-rest-client
Java library to convert MJML templates to HTML
Stars: ✭ 16 (-67.35%)
Mutual labels:  mjml
tde-webpack-mjml-plugin
Webpack plugin for converting MJML files to HTML
Stars: ✭ 12 (-75.51%)
Mutual labels:  mjml
mjml-bundle
✉️ Symfony bundle for MJML
Stars: ✭ 87 (+77.55%)
Mutual labels:  mjml
rss-to-email
Generate HTML emails from your RSS feeds.
Stars: ✭ 92 (+87.76%)
Mutual labels:  mjml
plugin-grapesjs-builder
GrapesJS HTML and MJML integration for Mautic
Stars: ✭ 42 (-14.29%)
Mutual labels:  mjml
zahper
Zahper - The power of MJML into Laravel newsletters
Stars: ✭ 13 (-73.47%)
Mutual labels:  mjml
language-mjml
Atom Editor package providing syntax support for MJML
Stars: ✭ 48 (-2.04%)
Mutual labels:  mjml
shopify-mail-notifications
Blazing-fast Shopify mail notifications templating environment with Liquid, MJML and Twig
Stars: ✭ 25 (-48.98%)
Mutual labels:  mjml
mjml-server
MJML wrapped in Express for use over HTTP
Stars: ✭ 31 (-36.73%)
Mutual labels:  mjml

MJML Ruby

Gem CI

[!] REQUIRES NODEJS

MJML parser and template engine for Ruby. Allows to create email templates without mess.

Install

Add to Gemfile:

gem 'mjml-ruby', '~> 0.4', require: 'mjml'

or

$ gem install mjml-ruby

Install NodeJS and MJML (both installations will works local and global).

$ npm install -g mjml@^3.0.0
$ bundle install

Usage

MJML v3

MJML v3 had added validation for templates and it breaks mjml-ruby v0.2.x if your template was invalid. mjml-ruby > v0.3.x has validation_level option(:soft by default) and allows to use old templates with v3. All validation errors will be logged.

Example:

MJML.configure do |config|
  config.validation_level = :soft # :skip/:soft/:strict
end

With Rails

<!-- app/views/layouts/mailer.html.mjml -->

<mjml>
  <mj-body>
    <mj-container>
      <%= yield %>
    </mj-container>
  </mj-body>
</mjml>
<!-- app/views/welcome_mailer/welcome.html.mjml -->

<mj-text>Hello, <%= @user.name %></mj-text>
class WelcomeMailer < ApplicationMailer
  def welcome(user)
    @user = user
    mail(to: @user.email, subject: 'Welcome')
  end
end

With Tilt

<!-- templates/hello.mjml -->

<mjml>
  <mj-body>
    <mj-container>
      <mj-text>Hello, world!</mj-text>
    </mj-container>
  </mj-body>
</mjml>
require 'tilt'
require 'mjml'

template = Tilt.new('templates/hello.mjml')
template.render # returns compiled HTML

With mail gem

<!-- hello.mjml -->

<mjml>
  <mj-body>
    <mj-container>
      <mj-text>Hello, world!</mj-text>
    </mj-container>
  </mj-body>
</mjml>
require 'mail'
require 'mjml'

template = File.open('hello.mjml', 'rb') { |f| MJML::Parser.new.call(f) }

Mail.deliver do
  from '[email protected]'
  to '[email protected]'
  subject 'Hello'
  body template
end

Configuration

# Change default mjml executable

# Regular Ruby
MJML.configure do |config|
  config.bin_path = '/usr/bin/env mjml'
  config.logger = YourLogger.new(STDOUT)
  config.minify_output = true
  config.validation_level = :soft
end

# Rails
Rails.application.configure do
  config.mjml.bin_path = '/usr/bin/env mjml'
  config.mjml.logger = MJML::Logger.setup!(STDOUT)
  config.mjml.minify_output = true
  config.mjml.validation_level = :soft
end

Deprecations

v0.3

  • config.debug = true is deprecated. If you are using default MJML Logger use config.logger.level = ::Logger::DEBUG instead.

TODO

  • Create parser
  • Make it configurable
  • Create Tilt interface
  • Create Sprockets interface
  • Create Railtie
  • Setup Travis
  • Add usage guide
  • Fix tests on CI
  • Add more tests
  • Improove docs
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].