Sharing colors between SASS files and Rails erb templates

I am working on an e-newsletter using the ActionMailer associated with our Rails 3.0.7. Therefore, despite all my instincts, I use built-in styles such as crazy because this is the only way to do something in an html email. I also want the color scheme to fit the website in a dry way.

Can I use shared SASS color variables between a Rails application and its SCSS files for use in an inline style?

+4
source share
2 answers

The only way I know this is to add .erb to your sass files so that they are processed by Rails, then you can use application level constants:

<%= APP_CONFIG[:yourkey] %> 

Similar question / more detailed description

Encoding emails is such a disgusting task that I try to turn off all areas of higher thinking in my brain that worry about good programming principles every time I do it. If email is not a central part of this project, I would refrain from obstacles affecting the rest of your project.

+2
source

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

The post-processing of your HTML with premieres includes all the CSS defined in a separate stylesheet, letting you specify what you want in the SASS or CSS file.

0
source

Source: https://habr.com/ru/post/1381547/


All Articles