Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/srghma/mjml-premailer
#mjml #rails #premailer
https://github.com/srghma/mjml-premailer
activemailer mjml mjml-framework premailer rails
Last synced: 19 days ago
JSON representation
#mjml #rails #premailer
- Host: GitHub
- URL: https://github.com/srghma/mjml-premailer
- Owner: srghma
- License: apache-2.0
- Created: 2018-07-06T16:16:21.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2024-03-07T06:56:38.000Z (10 months ago)
- Last Synced: 2024-11-27T12:13:51.320Z (26 days ago)
- Topics: activemailer, mjml, mjml-framework, premailer, rails
- Language: Ruby
- Homepage:
- Size: 226 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# mjml-premailer
Write your emails using [mjml framework](https://mjml.io) on rails, using any template language supported by Rails
[![Travis](https://travis-ci.org/srghma/mjml-premailer.svg?branch=master)](https://travis-ci.org/srghma/mjml-premailer)
[![Gem Version](https://badge.fury.io/rb/mjml-premailer.svg)](https://badge.fury.io/rb/mjml-premailer)
[![Maintainability](https://api.codeclimate.com/v1/badges/87ecd26fdfceb00dacb6/maintainability)](https://codeclimate.com/github/srghma/mjml-premailer/maintainability)
[![Coverage Status](https://coveralls.io/repos/github/srghma/mjml-premailer/badge.svg?branch=master)](https://coveralls.io/github/srghma/mjml-premailer?branch=master)## How it works
This gem will processes html part of your mail using `mjml` cli before delivery, just use `mjml_mail` function for delivery instead of `mail`
```rb
class ApplicationMailer < ActionMailer::Base
include MjmlPremailer::MjmlMail # adds function `mjml_mail`layout "mailer"
end
``````rb
class WelcomeMailer < ApplicationMailer
def welcome(user)
@user = user
mjml_mail(to: @user.email, subject: 'Welcome')
end
end
``````erb
My site
<%= yield %>
```
```erb
Hello, <%= @user.name %>
```Or you can transform mail object yourself using
```ruby
MjmlPremailer::TransformMail.transform_mail(mail)
```Example rails project you can find [here](example)
Mjml documentation is [here](https://mjml.io/documentation)
## Installation
Install `mjml` npm package (v4) globally
```sh
$ npm install -g mjml@^4.0
```or locally
```sh
$ npm install --save-dev mjml@^4.0
```Add the gem to your `Gemfile`:
```ruby
gem "mjml-premailer"
```## Configuration options
In `/config/initializers/mjml_premailer.rb`
```ruby
MjmlPremailer.config.merge!(
minify: Rails.env.production?, # default - false
beautify: !Rails.env.production?, # default - true
keep_comments: !Rails.env.production?, # default - false## other possible options
# debug: false, # default - false
# bin: ..., # by default bin path is found authomatically, but you can specify it here
# validation_level: :skip # default - :skip, possible options - :strict/:soft/:skip
)
```More about options [here](https://mjml.io/documentation/#command-line-interface)
## Difference from other gems
[sighmon/mjml-rails](https://github.com/sighmon/mjml-rails):
- no support for `/app/views/layouts`[kolybasov/mjml-ruby](https://github.com/kolybasov/mjml-ruby/):
- best gem I found, this gem is based on it, thanks [kolybasov](https://github.com/kolybasov) for his work
- doesnt support mjml v4 (at time of writing)
- doesnt support template languages other then erb (at least I didnt managed)## Hacking
```
make run_env
make test
make publish
```