A Rails plugin to enable layouts for ActionMailer templates.
The same way you install all Rails plugins. At the root of your Rails app, issue the command:
script/plugin install http://svn.cardboardrocket.com/action_mailer_layouts
Installing this plugin will add a new 'layout' property to the ActionMailer::Base class. Specify the name of the layout template you want to use. The plugin will look in app/views/layouts for your layout. If no layout is specified, the plugin will look for a layout that matches the name of your mailer class.
If your mailer class is called UserNotifier and you are rendering the activation.rhtml template, then the plugin will attempt to load the user_notifier.rhtml layout. Or, if you are rendering the activation.text.html.rhtml template, the plugin will look for the user_notifier.text.html.rhtml layout.
You can overload this behavior by setting the layout property of your mailer:
- class UserNotfier < ActionMailer::Base
- def activation(user)
- @recipients = user.email
- @from = 'you@ domain.com'
- @sent_on = Time.now
- @subject = 'Activate your account!'
- @layout = :email
- end
- end
This arrangement will cause the plugin to render the content in views/user_notifier/activation.text.html.rhtml in the views/layouts/email.text.html.rhtml layout.
The plugin is licensed under the MIT License.
Directly to me via email.
All content ©2006-2008 Alex Wolfe, all rights reserved, back to top ↩