conversionfoundry / breeze

A Ruby on Rails CMS for brochure-style websites.
Other
3 stars 2 forks source link

Added support for theming email messages (fixes #99) #100

Closed isaacfreeman closed 11 years ago

isaacfreeman commented 11 years ago

fixes #99

albandiguer commented 11 years ago

Thanks Isaac,

I have questions :innocent:

isaacfreeman commented 11 years ago

We should check all active themes, but there's no default theme. If no theme has a layout for the email, we should get a relative path that matches a subdirectory in views.

For example, in Breeze Commerce, I have default templates in

breeze_commerce/app/views/breeze/commerce/order_mailer/

If I want the template "new_order_merchant_notification.html.haml", I call

template_path('breeze/commerce/order_mailer/new_order_merchant_notification')

...so I'll either get a template path

<theme.path>/mail_templates/breeze/commerce/order_mailer/new_order_merchant_notification

or, if there's no theme template, from

/breeze/commerce/order_mailer/new_order_merchant_notification

the latter should match any engine that declares the template, or the parent app, so developers can hard-code a template if they prefer not to make it available in a theme.

I think this behaviour is fairly consistent with how Breeze works for other theme files.

I note that I've neglected a couple of things:

  1. Checking only the active (enabled) themes
  2. Ensuring that the themes are checked in the order determined by the admin dragging and dropping the themes
    • that looks quite consuming to create arrays and check inclusions over tens of string, maybe you could use File.exists? *

Quite possibly. I'd like to press on with other work right now, so perhaps we can open an issue for this.

That makes sense. The only reason theme_path and template_path are separate methods is that I wasn't certain that theme_path belonged in Breeze::Mailer.