maildown 3.0.3 → 3.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (24) hide show
  1. checksums.yaml +4 -4
  2. data/lib/maildown/ext/action_mailer.rb +18 -2
  3. data/lib/maildown/handlers/markdown.rb +12 -6
  4. data/lib/maildown/version.rb +1 -1
  5. data/lib/maildown.rb +2 -8
  6. data/test/dummy/db/test.sqlite3 +0 -0
  7. data/test/dummy/log/test.log +2440 -0
  8. data/test/dummy/tmp/cache/assets/sprockets/v3.0/A3/A3kbR-mx77BuTQCXH_ow0ly8c8774_qjKkbRwg7o7Z8.cache +0 -0
  9. data/test/dummy/tmp/cache/assets/sprockets/v3.0/Ky/KyPopZ9bAZSzDxl0-5H4oSWt6v3Hscx-IqtKCez5N6M.cache +1 -0
  10. data/test/dummy/tmp/cache/assets/sprockets/v3.0/LQ/LQc7CZbqyqSrstnlW82z5LYgsBPDE-bOnyAvkzwGyZE.cache +1 -0
  11. data/test/dummy/tmp/cache/assets/sprockets/v3.0/Qs/QsuZC0N-5s9LoiQKU5bmb9ddCBVsqqcG23hRRSzaNzI.cache +1 -0
  12. data/test/dummy/tmp/cache/assets/sprockets/v3.0/Sg/SgGPXJGAAT9BnlD8lOEY30CrwX2Ww8GNvkz1_06BUuY.cache +0 -0
  13. data/test/dummy/tmp/cache/assets/sprockets/v3.0/XL/XL_FTz0ksBA62QtuUFTEXWp6sbxjcinWNxVRvwewdVQ.cache +0 -0
  14. data/test/dummy/tmp/cache/assets/sprockets/v3.0/bG/bGAz7aV3zTfJzCyTFZJ3JHHiggWMmTL8_sjwIrZof48.cache +0 -0
  15. data/test/dummy/tmp/cache/assets/sprockets/v3.0/hN/hNuDCLtFB8vWAB97u08o2jUz_JOaHtcRL85mfok6rKE.cache +0 -0
  16. data/test/dummy/tmp/cache/assets/sprockets/v3.0/hj/hj8Ir9wcVSy1KYrnWu9bpD24vDhCG3tvt-nKbNxb1Wg.cache +2 -0
  17. data/test/dummy/tmp/cache/assets/sprockets/v3.0/hz/hzfOEnv86cyXvfNc1ID57ERgXFQbUWy0mA_2kb8RMf8.cache +1 -0
  18. data/test/dummy/tmp/cache/assets/sprockets/v3.0/lL/lLPqCyZWuBhuo1Cc2h2NkRzr8qk4bog-PvgUZj9eD9A.cache +0 -0
  19. data/test/dummy/tmp/cache/assets/sprockets/v3.0/oC/oCsZTGZyV4kH8Y4OeSDUdrwfkJFPzTODZjuBKZB8oGQ.cache +2 -0
  20. data/test/dummy/tmp/cache/assets/sprockets/v3.0/q6/q6BYa32YJF11eGVapO4ouNl6gayPIsARgMavlzZmoi0.cache +2 -0
  21. data/test/dummy/tmp/cache/assets/sprockets/v3.0/x7/x7KkTV3ibfIEysLB_ug5bfmnn2VLV_BldukPR3EoPBk.cache +2 -0
  22. data/test/dummy/tmp/cache/assets/sprockets/v3.0/xq/xqUVzvrduT5J0NftyOoRYuGT8PShk-KqKJrZbf_u63o.cache +1 -0
  23. data/test/dummy/tmp/cache/assets/sprockets/v3.0/zj/zjBh6TAy1PfMo7ob2ifDemYXiSU1gF4Hed-g-jXHYuQ.cache +0 -0
  24. metadata +36 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3d27d44e89e7c9ba1d896e9c108438014822262f5d7227ee1d9af2fd6c94a33f
4
- data.tar.gz: ba13353f957683acb4c5962c7acf6768a170e6b842d5227b9f1ac601ee51fe89
3
+ metadata.gz: '01758860c9ca7fca23b95b27bd10a98976b52c325c0e34ad296af871b9bdc3ba'
4
+ data.tar.gz: 14169956b1e4ca0f9cafb55b89785d4ba30e61e331f880fe32207434f6e30980
5
5
  SHA512:
6
- metadata.gz: e743440ed6a2e1f504e3ad8e9f8fbf9cebadf9f05c913d443a2622beb110625847913e2c629e9993972d9b30067b39c35a9ad4c169d3fd2df24f5b2a04bb85ec
7
- data.tar.gz: d8e41bbdd61b74ec7e5527a7a4e46dff6ad85bafde92a2f22f07e039cab6db0ba7d6c01e0f21ab0ff8969ad1c3a1e9bac59200d37c046f9a97abfe78a0685bef
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
- text_template = html_template.instance_variable_get(:"@maildown_text_template")
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 http://rubular.com/r/uCXQ58OOC8
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
- compiled_source = erb_handler.call(template)
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 template.formats.include?(:html)
39
- return "Maildown::MarkdownEngine.to_html(begin;#{compiled_source}; end)"
45
+ if is_html
46
+ "Maildown::MarkdownEngine.to_html(begin;#{compiled_source}; end)"
40
47
  else
41
- return "Maildown::MarkdownEngine.to_text(begin;#{compiled_source}; end)"
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
-
@@ -1,3 +1,3 @@
1
1
  module Maildown
2
- VERSION = "3.0.3"
2
+ VERSION = "3.1.0"
3
3
  end
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.enable_layouts
15
- puts "Maildown.enable_layouts is deprecated, setting this does nothing"
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