maildown 3.0.3 → 3.1.0
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.
- checksums.yaml +4 -4
- data/lib/maildown/ext/action_mailer.rb +18 -2
- data/lib/maildown/handlers/markdown.rb +12 -6
- data/lib/maildown/version.rb +1 -1
- data/lib/maildown.rb +2 -8
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/test.log +2440 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/A3/A3kbR-mx77BuTQCXH_ow0ly8c8774_qjKkbRwg7o7Z8.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/Ky/KyPopZ9bAZSzDxl0-5H4oSWt6v3Hscx-IqtKCez5N6M.cache +1 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/LQ/LQc7CZbqyqSrstnlW82z5LYgsBPDE-bOnyAvkzwGyZE.cache +1 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/Qs/QsuZC0N-5s9LoiQKU5bmb9ddCBVsqqcG23hRRSzaNzI.cache +1 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/Sg/SgGPXJGAAT9BnlD8lOEY30CrwX2Ww8GNvkz1_06BUuY.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/XL/XL_FTz0ksBA62QtuUFTEXWp6sbxjcinWNxVRvwewdVQ.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/bG/bGAz7aV3zTfJzCyTFZJ3JHHiggWMmTL8_sjwIrZof48.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/hN/hNuDCLtFB8vWAB97u08o2jUz_JOaHtcRL85mfok6rKE.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/hj/hj8Ir9wcVSy1KYrnWu9bpD24vDhCG3tvt-nKbNxb1Wg.cache +2 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/hz/hzfOEnv86cyXvfNc1ID57ERgXFQbUWy0mA_2kb8RMf8.cache +1 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/lL/lLPqCyZWuBhuo1Cc2h2NkRzr8qk4bog-PvgUZj9eD9A.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/oC/oCsZTGZyV4kH8Y4OeSDUdrwfkJFPzTODZjuBKZB8oGQ.cache +2 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/q6/q6BYa32YJF11eGVapO4ouNl6gayPIsARgMavlzZmoi0.cache +2 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/x7/x7KkTV3ibfIEysLB_ug5bfmnn2VLV_BldukPR3EoPBk.cache +2 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/xq/xqUVzvrduT5J0NftyOoRYuGT8PShk-KqKJrZbf_u63o.cache +1 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/zj/zjBh6TAy1PfMo7ob2ifDemYXiSU1gF4Hed-g-jXHYuQ.cache +0 -0
- metadata +36 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '01758860c9ca7fca23b95b27bd10a98976b52c325c0e34ad296af871b9bdc3ba'
|
4
|
+
data.tar.gz: 14169956b1e4ca0f9cafb55b89785d4ba30e61e331f880fe32207434f6e30980
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aed376205a32a77f541cf38f76f688442b32a973f0e6347c89f8f563df710018e8c7b95f6a9be5abd1cf913a0eaa1c81d62866a5674375a0e96c1cc590ed68a9
|
7
|
+
data.tar.gz: 479863668fba294112810de76285007380749d8d82b6f35c3cb19b2cb7447f0ddf7d1a10bfe470eb35b3f7c783b7e6f0293b04de1537c9dc5ed16b70bd3d3039
|
@@ -45,16 +45,32 @@ class ActionMailer::Base
|
|
45
45
|
return templates if templates.first.handler != Maildown::Handlers::Markdown
|
46
46
|
|
47
47
|
html_template = templates.first
|
48
|
+
|
49
|
+
# Cached template is already defined
|
48
50
|
if html_template.instance_variable_defined?(:"@maildown_text_template")
|
49
|
-
|
51
|
+
text_template = html_template.instance_variable_get(:"@maildown_text_template")
|
52
|
+
return [html_template, text_template]
|
53
|
+
end
|
54
|
+
|
55
|
+
if Maildown.rails_6?
|
56
|
+
text_template = html_template
|
57
|
+
.class
|
58
|
+
.new(
|
59
|
+
html_template.source,
|
60
|
+
html_template.identifier,
|
61
|
+
html_template.handler,
|
62
|
+
format: :text,
|
63
|
+
locals: html_template.locals
|
64
|
+
)
|
50
65
|
else
|
51
66
|
text_template = html_template.dup
|
52
67
|
formats = html_template.formats.dup.tap { |f| f.delete(:html) }
|
53
68
|
|
54
69
|
text_template.formats = formats
|
55
|
-
html_template.instance_variable_set(:"@maildown_text_template", text_template)
|
56
70
|
end
|
57
71
|
|
72
|
+
html_template.instance_variable_set(:"@maildown_text_template", text_template)
|
73
|
+
|
58
74
|
return [html_template, text_template]
|
59
75
|
end
|
60
76
|
end
|
@@ -30,15 +30,22 @@ module Maildown
|
|
30
30
|
# with Rails 5.0+.
|
31
31
|
source ||= template.source
|
32
32
|
|
33
|
-
# Match beginning whitespace but not newline
|
33
|
+
# Match beginning whitespace but not newline
|
34
|
+
# http://rubular.com/r/uCXQ58OOC8
|
34
35
|
source.gsub!(/^[^\S\n]+/, ''.freeze) if Maildown.allow_indentation
|
35
36
|
|
36
|
-
|
37
|
+
if Maildown.rails_6?
|
38
|
+
compiled_source = erb_handler.call(template, source)
|
39
|
+
is_html = (template.format != :text)
|
40
|
+
else
|
41
|
+
compiled_source = erb_handler.call(template)
|
42
|
+
is_html = template.formats.include?(:html)
|
43
|
+
end
|
37
44
|
|
38
|
-
if
|
39
|
-
|
45
|
+
if is_html
|
46
|
+
"Maildown::MarkdownEngine.to_html(begin;#{compiled_source}; end)"
|
40
47
|
else
|
41
|
-
|
48
|
+
"Maildown::MarkdownEngine.to_text(begin;#{compiled_source}; end)"
|
42
49
|
end
|
43
50
|
end
|
44
51
|
end
|
@@ -61,4 +68,3 @@ ActionView::Template.register_template_handler :"md", Maildown::Handlers::Ma
|
|
61
68
|
# to allow rails to even attempt to process the file, it needs this
|
62
69
|
# handler with ".md.erb" to be registered.
|
63
70
|
ActionView::Template.register_template_handler :"md.erb", Maildown::Handlers::Markdown
|
64
|
-
|
data/lib/maildown/version.rb
CHANGED
data/lib/maildown.rb
CHANGED
@@ -11,14 +11,8 @@ module Maildown
|
|
11
11
|
@allow_indentations = allow_indentations
|
12
12
|
end
|
13
13
|
|
14
|
-
def self.
|
15
|
-
|
16
|
-
@enable_layouts
|
17
|
-
end
|
18
|
-
|
19
|
-
def self.enable_layouts=(enable_layouts)
|
20
|
-
puts "Maildown.enable_layouts= is deprecated, setting this does nothing"
|
21
|
-
@enable_layouts = enable_layouts
|
14
|
+
def self.rails_6?
|
15
|
+
@rails_6 ||= Rails.version > "6"
|
22
16
|
end
|
23
17
|
end
|
24
18
|
|
File without changes
|