Inlining CSS in ActionMailer 3 (Rails 3.0) July 8th, 2010
As most of you already know, a bunch of online mail readers (like Hotmail, Gmail, …) don’t handle stylesheets very well, they prefer inline styling (
TamTam is a gem created by Dave Hoover and Brian Tatnall that does all the dirty work for us. Before Rails 3 there was a plugin called inline_css (by the same authors) that used TamTam to automatically inlined all mails sent by ActionMailer. Since Rails 3, however, the ActionMailer internals have changed, and the plugin stopped working.
For my own use I created a module called InlineCss that I include in the mailers I need inlining for. This is the code:
module InlineCss def render(*args) if (template = args.first[:template]) && template.mime_type.html? # Be warned, this code expects a <style> tag in the head of your layout. TamTam.inline(:document => super) else super end end end
This code sees if I am working with a template and if that template has a HTML MIME-type, it inline’s it with TamTam.
In my mailers I just include it. If you want to have this in all mailers, just add an initializer that includes InlineCss in ActionMailer::Base, and it should work
l
Very well written. The script is very useful and helpful, many thanks!
Very well written. The script is very useful and helpful, many thanks!
The css file editing can be done with DreamWeaver or with notepad, too.
I think the idea of css is to reduce the space necessary for the browser.
Reading is my passion. Browsing through your site gives me a lot of knowledge in so many ways. Best Sunglasses
There are different ways in which you might want to set up a complete development environment for Ruby on Rails on a Windows machine. I like to discuss more about this thanks for sharing. Regards, Jack
Thank you for this information. I’ve been looking for something like this for quite a while. Keep up the good work, cheers! klimat thailand lången tips filippinerna
Very well written. The script is very useful and helpful, many thanks!what does it mean when you dream about someone fh what does it mean when your eye twitches
I will get to know more new information. Even the website layouts and the designs impress me a lot. Minoterie pour farine
The concepts have however been extended from their computing and telecommunication meanings into the area of human interaction and conversation, such that even offline can be used in contrast to the common usage of online. Thanks.
Thanks for a good post. I think the idea of css to recude space is necessary.
Thanks for a good post. Its great that you are posting stuff like this.
Great post! Keep them coming like this. There is too much bad blogs out there, but this is one of the good ones.
I want to share this information with my friends I hope the will also like it.
So this is what happened with me, anyways its a confirming toil, I revalue it. Thanks
A typical event features several vignettes of the daily everyday life of a pair with the camera mostly centered upon them, often cropping out other font, giving it its unique visual style.
In my mailers I just include it. If you want to have this in all mailers, just add an initializer that includes InlineCss in ActionMailer::Base, and it should work
Local per-repo rules can be added to the .git/info/exclude file in your repo. These rules are not committed with the repo so they are not shared with others. This method can be used for locally-generated files that you don’t expect other users to generate, like files created by your editor.
..qui eussent aim¨¦ prendre l’air? Le si¨¨cle dernier aurait-on imagin¨¦ nommer L¨¦on Zitrone ministre des sports?
Observateur, la qualifiant d¡¯infâme¡ Notre Ministre de la Culture visiblement ne supporte pas la critique.
Was pleased reading about this stuff. Thanks! buy college essays
In Ireland religion is taught in a subject called holy Education which is necessary in many schools for the Junior record, but available as an option for the Leaving diploma.
Thank you for sharing your blog. I came across it just recently and I am very impressed. Keep it going.
Can I just say, this blog is what got me through the day today. Every time I read it, I just get more and more excited about whats next. Very refreshing blog and very refreshing ideas. Im glad that I came across this when I did. I love what youve got to say and the way you say it. Printing
Våffeljärn
These rules are not committed with the repo so they are not shared with others. This method can be used for locally-generated files that you don’t expect other users to generate, like files created by your editor.Azithromycin uses
Bygga garage
Byta fönster
I think the idea of css is to reduce the space necessary for the browser.
Images fashion strives to provide a balance of timely, credible business news and key fashion trends. fashion apparel news
The concepts have however been extended from their computing and caplan syndrome telecommunication meanings into the area of human interaction and conversation, such that even offline can be used in contrast to the common usage of online.
I am really looking forward to skiing there. It is so very pretty and amazing there. Hopefully I can visit there one day. Residential plots in gurgaon
My spouse and i esteem the particular helpful data a person supply with your content. I most certainly will search for your site in addition to click here frequently.
good work keep it up
It is a wonderful blog. It helps me out a lot. Thank you. I really need help in development and blogs like yours are very helpful.
Keep it creative, didnt you all know thats the key to make it in this world.
Happy like a pancake! Shake shake, this made my day.
It is a wonderful blog. It helps me out a lot. Thank you. I really need help in development and blogs like yours are very helpful.
I’m definitely tired of struggling to find relevant and intelligent comments on this topic. Everybody today seems to go to extremes to either drive home their views or suggest that anyone else in the world is wrong. Thank you for your accurate and relevant insights.
Please tell me that youre going to keep this up! Its so good and so important. I cant wait to read more from you.
I just feel like you know so much and know how to make people listen to what you have to say. This blog is just too cool to be missed. Great stuff, really. Please, PLEASE keep it up!