Phlex for Rails Emails: Action Mailer without ERB - Camillo Visini
07-Mar-2025 36
Writing Ruby all day is fun, but writing Ruby in HTML is not. In the past months, I found switching from Ruby to ERB views and partials to be interrupting my flow and therefore increasingly annoying. Enter Phlex, which is a Ruby library that allows you to write HTML (components, views, layouts) in pure Ruby. After already completely ditching ERB for Phlex in Rails views for multiple applications, I wanted to see if I could do the same for Action Mailer. ERB be gone!
Why might this be interesting, besides just trying it out for the sake of it, and to see if it’s possible? I see these benefits:
No more ERB: Use Phlex all the way, even for mailers
Manage the HTML and text version of the email in one place
Use Phlex components for layouts and views.
Phlex for Rails Emails: Action Mailer without ERB - Camillo Visini #ruby #rubydeveloper #rubyonrails #Phlex #Rails #Emails: #Action #Mailer #without #Camillo #Visini https://rubyonrails.ba/link/phlex-for-rails-emails-action-mailer-without-erb-camillo-visini