aboutsummaryrefslogtreecommitdiffstats
path: root/lib/attachment_to_html
diff options
context:
space:
mode:
Diffstat (limited to 'lib/attachment_to_html')
-rw-r--r--lib/attachment_to_html/attachment_to_html.rb1
-rw-r--r--lib/attachment_to_html/template.html.erb13
-rw-r--r--lib/attachment_to_html/view.rb27
3 files changed, 41 insertions, 0 deletions
diff --git a/lib/attachment_to_html/attachment_to_html.rb b/lib/attachment_to_html/attachment_to_html.rb
index 5f63661b4..104dc13e2 100644
--- a/lib/attachment_to_html/attachment_to_html.rb
+++ b/lib/attachment_to_html/attachment_to_html.rb
@@ -1,4 +1,5 @@
require 'html'
+require 'view'
Dir[File.dirname(__FILE__) + '/adapters/*.rb'].each do |file|
require file
diff --git a/lib/attachment_to_html/template.html.erb b/lib/attachment_to_html/template.html.erb
new file mode 100644
index 000000000..9d3068ce2
--- /dev/null
+++ b/lib/attachment_to_html/template.html.erb
@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title><%= title %></title>
+</head>
+<body>
+ <div id="<%= wrapper %>">
+ <div id="view-html-content">
+ <%= body %>
+ </div>
+ </div>
+</body>
+</html>
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