# frozen_string_literal: true require 'kramdown' require 'erubis' module Lipstick class EmailMessage attr_reader :title, :image_url, :content, :template def initialize(title:, content:, image_url:, template: default_template) @title = title @content = Kramdown::Document.new(content).to_html @image_url = image_url @template = template end def render Erubis::Eruby.new(template).result(binding) end private TEMPLATE_PATH = '../../app/views/layouts/email_branding.html.erb' private_constant :TEMPLATE_PATH def default_template file = File.expand_path(TEMPLATE_PATH, File.dirname(__FILE__)) File.read(file) end end end