4

I'm working on an email newsletter using ActionMailer that's associated to our Rails 3.0.7 application. So against all my instincts, I'm using inline styles like mad since that seems to be the only way to do things in html email. I'd also like to keep the color scheme consistent with the website in a DRY fashion.

Is there any way to share SASS color variables between a Rails application and its SCSS files for use in inline styling?

Lucas Wiman
  • 10,021
  • 2
  • 37
  • 41
  • i guess this should be doable with 3.1 and the asset pipeline where you can do scss.erb files – phoet Nov 16 '11 at 20:49

2 Answers2

2

The only way I'm aware you can do this is to add .erb onto your sass files so that they're processed by Rails, then you can use application level constants:

<%= APP_CONFIG[:yourkey] %>

Similar question / more reading

Coding emails is such a heinous task that I try to turn off all the higher thinking regions of my brain that worry about good programming principles every time I have to do it. Unless email is the central part of this project I'd resist letting the constraints there affect the rest of your application design.

Community
  • 1
  • 1
RSG
  • 7,013
  • 6
  • 36
  • 51
  • Thanks for this. I've thus far ended up going with your suggestion of just hacking things together, but I may end up redesigning some parts of the application to better support email. Unfortunately, email is absolutely essential to our product, and we have plans for more different kinds of emails, so DRY will start to become more important. – Lucas Wiman Jan 05 '12 at 18:23
0

Best solution I've found so far is the premailer gem: https://github.com/alexdunae/premailer/

Post-processing your HTML with premailer inlines all the CSS defined in a separate stylesheet, letting you specify whatever you want in a SASS or CSS file.

Lucas Wiman
  • 10,021
  • 2
  • 37
  • 41