class AwsSesNewsletters::HtmlBuilder
Helper that allows you to build html from erb templates, inlines css as needed in emails
Attributes
template_name[RW]
Public Class Methods
new(template_name, instance_variables_hash = nil)
click to toggle source
# File lib/aws_ses_newsletters/html_builder.rb, line 12 def initialize(template_name, instance_variables_hash = nil) @template_name = template_name instance_variables_hash.each { |name, value| instance_variable_set("@#{name}", value) } if instance_variables_hash.present? end
Public Instance Methods
build()
click to toggle source
# File lib/aws_ses_newsletters/html_builder.rb, line 17 def build template = File.read(template_name) renderer = ERB.new(template) html_string = renderer.result(get_binding) inline_html_string = ::Premailer.new(html_string, warn_level: Premailer::Warnings::SAFE, with_html_string: true).to_inline_css return inline_html_string.gsub(/\n/, "") end
get_binding()
click to toggle source
# File lib/aws_ses_newsletters/html_builder.rb, line 25 def get_binding binding() end