aboutsummaryrefslogtreecommitdiffstats
path: root/lib/attachment_to_html/view.rb
diff options
context:
space:
mode:
authorGareth Rees <gareth@mysociety.org>2014-04-02 11:28:45 +0100
committerGareth Rees <gareth@mysociety.org>2014-04-07 16:11:14 +0100
commitea1e040780f00938331e92472780c91b7e0f43a2 (patch)
tree15ca51d2d8d66185f05e253dbef419adafc98692 /lib/attachment_to_html/view.rb
parent08572fe8d0ad97c01ecc5c0f0ee39e610de383a3 (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.rb27
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