diff options
author | Gareth Rees <gareth@mysociety.org> | 2014-04-02 11:28:45 +0100 |
---|---|---|
committer | Gareth Rees <gareth@mysociety.org> | 2014-04-07 16:11:14 +0100 |
commit | ea1e040780f00938331e92472780c91b7e0f43a2 (patch) | |
tree | 15ca51d2d8d66185f05e253dbef419adafc98692 /lib/attachment_to_html/view.rb | |
parent | 08572fe8d0ad97c01ecc5c0f0ee39e610de383a3 (diff) |
Add an AttachmentToHTML::View to deal with rendering
Diffstat (limited to 'lib/attachment_to_html/view.rb')
-rw-r--r-- | lib/attachment_to_html/view.rb | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/lib/attachment_to_html/view.rb b/lib/attachment_to_html/view.rb new file mode 100644 index 000000000..5cdd3823b --- /dev/null +++ b/lib/attachment_to_html/view.rb @@ -0,0 +1,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 |