Skip to content

Commit

Permalink
replace mailer.html.erb layout by default; backup existing mailer.htm…
Browse files Browse the repository at this point in the history
…l.erb to old_mailer.html.erb; update README
  • Loading branch information
zokioki committed Jul 4, 2016
1 parent ffab770 commit 7bdb486
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 37 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
inky-rb (1.3.6.0)
inky-rb (1.3.6.1)
foundation_emails (~> 2)

GEM
Expand Down
43 changes: 9 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
# Inky

[![Gem Version](https://badge.fury.io/rb/inky-rb.svg)](https://badge.fury.io/rb/inky-rb)

Inky is an HTML-based templating language that converts simple HTML into complex, responsive email-ready HTML. Designed for [Foundation for Emails](http://foundation.zurb.com/emails), a responsive email framework from [ZURB](http://zurb.com).

To include only the Foundation for Emails styles in your Asset Pipeline, without Inky, use the [**foundation_emails**](https://github.com/zurb/foundation-emails/#using-the-ruby-gem) gem.

Give Inky simple HTML like this:

```html
Expand Down Expand Up @@ -52,50 +56,21 @@ Then execute:
bundle install
```

Make sure that the stylesheet included in your email layout imports the Foundation for Emails styles:

```scss
// app/assets/stylesheets/your_emails_stylesheet.scss
Run the following command to set up the required styles and mailer layout:

@import "foundation-emails";
```bash
rails g inky:install
```

(You can specify the generated mailer layout filename like so: `rails g inky:install some_name`)

Rename your email templates to use the `.inky` file extension. Note that you'll still be able to use ERB within the `.inky` templates:

```
welcome.html => welcome.html.inky
pw_reset.html.erb => pw_reset.html.inky
```

Ensure your mailer layout has the following structure:

```html
<!-- app/views/layouts/your_mailer_layout.html.erb -->

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- Enables media queries -->
<meta name="viewport" content="width=device-width"/>
<!-- Link to the email's CSS, which will be inlined into the email -->
<%= stylesheet_link_tag "your_emails_stylesheet" %>
</head>

<body>
<table class="body" data-made-with-foundation>
<tr>
<td class="center" align="center" valign="top">
<center>
<%= yield %>
</center>
</td>
</tr>
</table>
</body>
</html>
```

You're all set!

** The majority of email clients ignore linked stylesheets. By using a CSS inliner like `premailer-rails` or `roadie`, you're able to leave your stylesheets in a separate file, keeping your markup lean.
Expand Down
10 changes: 9 additions & 1 deletion lib/generators/inky/install_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,15 @@ module Generators
class InstallGenerator < ::Rails::Generators::Base
desc 'Install Foundation for Emails'
source_root File.join(File.dirname(__FILE__), 'templates')
argument :layout_name, :type => :string, :default => 'inky_mailer', :banner => 'layout_name'
argument :layout_name, :type => :string, :default => 'mailer', :banner => 'layout_name'

def preserve_original_mailer_layout
return nil unless layout_name == 'mailer'

original_mailer = File.join(layouts_base_dir, 'mailer.html.erb')
rename_filename = File.join(layouts_base_dir, "old_mailer_#{Time.now.to_i}.html.erb")
File.rename(original_mailer, rename_filename) if File.exists? original_mailer
end

def create_mailer_stylesheet
template 'foundation_emails.scss', File.join(stylesheets_base_dir, 'foundation_emails.scss')
Expand Down
2 changes: 1 addition & 1 deletion lib/inky/rails/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Inky
module Rails
VERSION = "1.3.6.0"
VERSION = "1.3.6.1"
end
end

0 comments on commit 7bdb486

Please sign in to comment.