html_email_creator 1.0.7 → 1.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/html_email_creator/email.rb +19 -10
- data/lib/html_email_creator/version.rb +1 -1
- metadata +3 -3
@@ -3,7 +3,7 @@ require "liquid"
|
|
3
3
|
module HtmlEmailCreator
|
4
4
|
class Email
|
5
5
|
attr_reader :settings
|
6
|
-
|
6
|
+
|
7
7
|
def self.find_emails(file_or_directory, recursively = false)
|
8
8
|
if File.directory?(file_or_directory)
|
9
9
|
if recursively
|
@@ -33,23 +33,23 @@ module HtmlEmailCreator
|
|
33
33
|
end
|
34
34
|
@versions
|
35
35
|
end
|
36
|
-
|
36
|
+
|
37
37
|
# Renders email in a specific format
|
38
38
|
def render_only(format)
|
39
39
|
formatter = HtmlEmailCreator::Formatter.new(rendered_email, @settings).find(format)
|
40
40
|
HtmlEmailCreator::EmailVersion.new(formatter, output_basename, @settings)
|
41
41
|
end
|
42
|
-
|
42
|
+
|
43
43
|
# Convenience method for rendering HTML email.
|
44
44
|
def render_html_email
|
45
45
|
render_only(HtmlEmailCreator::Formatters::HtmlEmail.id)
|
46
46
|
end
|
47
|
-
|
47
|
+
|
48
48
|
# Convenience method for rendering plain text email.
|
49
49
|
def render_plain_text_email
|
50
50
|
render_only(HtmlEmailCreator::Formatters::PlainTextEmail.id)
|
51
51
|
end
|
52
|
-
|
52
|
+
|
53
53
|
private
|
54
54
|
|
55
55
|
def rendered_email
|
@@ -66,28 +66,37 @@ module HtmlEmailCreator
|
|
66
66
|
else
|
67
67
|
configuration
|
68
68
|
end
|
69
|
-
|
69
|
+
|
70
70
|
defaults = {
|
71
71
|
"output_formats" => ["plain_text_email", "html_email"]
|
72
72
|
}
|
73
|
-
|
73
|
+
|
74
74
|
config_hash.merge(defaults)
|
75
75
|
end
|
76
|
-
|
76
|
+
|
77
77
|
def output_basename
|
78
78
|
@configuration["config"]["output"]
|
79
79
|
end
|
80
|
-
|
80
|
+
|
81
81
|
def layout_path
|
82
82
|
File.join(@settings.layouts_path, @configuration["config"]["layout"])
|
83
83
|
end
|
84
|
-
|
84
|
+
|
85
85
|
def fill_blanks(layout)
|
86
86
|
filled_layout = layout.dup
|
87
|
+
|
88
|
+
# fill email specific content to layout
|
87
89
|
@configuration["config"]["data"].each_pair do |key, value|
|
88
90
|
filled_layout.gsub!(/\{\{\s*#{key}\s*\}\}/, value)
|
89
91
|
end
|
92
|
+
|
93
|
+
# fill also global settings content to layout
|
94
|
+
@settings.extension_data.each_pair do |key, value|
|
95
|
+
filled_layout.gsub!(/\{\{\s*#{key}\s*\}\}/, value)
|
96
|
+
end
|
97
|
+
|
90
98
|
filled_layout
|
91
99
|
end
|
100
|
+
|
92
101
|
end
|
93
102
|
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 1
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 1.0.
|
8
|
+
- 8
|
9
|
+
version: 1.0.8
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Pekka Mattila
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2011-11-
|
17
|
+
date: 2011-11-06 00:00:00 +02:00
|
18
18
|
default_executable: html_email_creator
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|