Sha256: 6aefd4911f356b5ebc755afc9d4bf802e4b72d2ee374782d432fcc7e9d907edf

Contents?: true

Size: 710 Bytes

Versions: 19

Compression:

Stored size: 710 Bytes

Contents

# 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

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
aaf-lipstick-4.10.0 lib/lipstick/email_message.rb
aaf-lipstick-4.9.2 lib/lipstick/email_message.rb
aaf-lipstick-4.9.1 lib/lipstick/email_message.rb
aaf-lipstick-4.9.0 lib/lipstick/email_message.rb
aaf-lipstick-4.8.0 lib/lipstick/email_message.rb
aaf-lipstick-4.7.0 lib/lipstick/email_message.rb
aaf-lipstick-4.6.0 lib/lipstick/email_message.rb
aaf-lipstick-4.5.1 lib/lipstick/email_message.rb
aaf-lipstick-4.4.0 lib/lipstick/email_message.rb
aaf-lipstick-4.3.0 lib/lipstick/email_message.rb
aaf-lipstick-4.2.0 lib/lipstick/email_message.rb
aaf-lipstick-4.1.0 lib/lipstick/email_message.rb
aaf-lipstick-4.0.1 lib/lipstick/email_message.rb
aaf-lipstick-3.2.0 lib/lipstick/email_message.rb
aaf-lipstick-3.1.0 lib/lipstick/email_message.rb
aaf-lipstick-3.0.6 lib/lipstick/email_message.rb
aaf-lipstick-3.0.5 lib/lipstick/email_message.rb
aaf-lipstick-3.0.4 lib/lipstick/email_message.rb
aaf-lipstick-3.0.2 lib/lipstick/email_message.rb