Part of this comes from how a convenient reaction made him have a small piece of template code with a component. Here is what I still have:
# app/mailers/membership_mailer.rb
I use this layout for all my emails and it is set as the default layout for application_mailer.
# app/views/layouts/email.html.slim = stylesheet_link_tag "email" header .shell h1 = yield :header .shell br = yield :body = yield = render partial: "/shared/email_footer"
I want all the rendering methods to be here, but I'm trying to find / figure out how to create a template for the mailer, layout and all the variables that I want to get are templates.
# app/mailers/application_mailer.rb # frozen_string_literal: true class ApplicationMailer < ActionMailer::Base default from: APPLICATION_CONFIG['support_email'] layout 'email' # taken from slim/test/block rendering / helper def slim(source, options = {}, &block) scope = options.delete(:scope) locals = options.delete(:locals) Slim::Template.new('', {}) { source }.render(scope, locals, &block) end end
In the end, I will have erb, arbre, etc.
So, in general, when I make a call to mail (...) {...}, I would like my template to be defined in ruby, and not in the template file, because I donβt like that the mail program and the template is still separated from each other (in the file system .. why is it beyond the scope of this question, I just want to solve the problem of rendering in ruby ββat the moment).