aboutsummaryrefslogtreecommitdiffstats
path: root/lib/attachment_to_html/view.rb
blob: 5cdd3823b1a4f15bb6187eea730e3c5eb4cf1303 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
module AttachmentToHTML
    class View < ERB

        def self.template
            @template || "#{ File.dirname(__FILE__) }/template.html.erb"
        end

        def self.template=(path)
            @template = path
        end

        attr_accessor :title, :body, :template, :wrapper

        def initialize(adapter, opts = {})
            self.title    = adapter.title
            self.body     = adapter.body
            self.template = opts.fetch(:template, self.class.template)
            self.wrapper  = opts.fetch(:wrapper, 'wrapper')
            super(File.read(template))
        end

        def render
            result(binding)
        end

    end
end