Sha256: 3a5adf2eafcab65c624e382aa630122cf1ea109a84f0b08a9aa884462e368293

Contents?: true

Size: 989 Bytes

Versions: 15

Compression:

Stored size: 989 Bytes

Contents

module EffectiveEmailTemplates
  class EmailViewTemplate
    def initialize( effective_email_template )
      @effective_email_template = effective_email_template
    end

    attr_accessor :locals
    attr_reader :effective_email_template

    def render(view, locals, buffer=nil, &block)
      # The view object here is an anonymous view object (it has a class
      # of Class). It has all of the view helper methods inside of it.

      if view.assigns['email_body']
        effective_email_template.body = view.assigns['email_body']
        effective_email_template.precompile

        if effective_email_template.errors[:template].present?
          raise "Email body error: #{effective_email_template.errors[:template].join('')}"
        end
      end

      effective_email_template.render(view.assigns['to_liquid'])
    end

    def formats
      [:html]
    end

    def identifier
      effective_email_template.slug
    end

    def type
      formats.first
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
effective_email_templates-0.6.0 lib/effective_email_templates/email_view_template.rb
effective_email_templates-0.5.1 lib/effective_email_templates/email_view_template.rb
effective_email_templates-0.5.0 lib/effective_email_templates/email_view_template.rb
effective_email_templates-0.4.6 lib/effective_email_templates/email_view_template.rb
effective_email_templates-0.4.5 lib/effective_email_templates/email_view_template.rb
effective_email_templates-0.4.4 lib/effective_email_templates/email_view_template.rb
effective_email_templates-0.4.3 lib/effective_email_templates/email_view_template.rb
effective_email_templates-0.4.2 lib/effective_email_templates/email_view_template.rb
effective_email_templates-0.4.1 lib/effective_email_templates/email_view_template.rb
effective_email_templates-0.4.0 lib/effective_email_templates/email_view_template.rb
effective_email_templates-0.3.5 lib/effective_email_templates/email_view_template.rb
effective_email_templates-0.3.4 lib/effective_email_templates/email_view_template.rb
effective_email_templates-0.3.3 lib/effective_email_templates/email_view_template.rb
effective_email_templates-0.3.1 lib/effective_email_templates/email_view_template.rb
effective_email_templates-0.3.0 lib/effective_email_templates/email_view_template.rb