maildown 2.0.2 → 2.0.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 03e4be44fd6d8f2dfc2ea77c9a8043a26ba75948be6843d21c96ff0b5a79b597
4
- data.tar.gz: ef13d877c6310a918f1f200f6a08d1b283552973e26606fc2b3e46ef6f2b1556
3
+ metadata.gz: 3015c6cd2855144aaa66368e064f210e38b9558f07eaeef739f4330e5d7325cb
4
+ data.tar.gz: 3e7ce8df93af569dad9ead634a7df86f9fcf75a5797858ab64f9485e0cbc95c7
5
5
  SHA512:
6
- metadata.gz: 61cb9dd93f18024cff25827f2106a012be77cdba0c1ce938a7213333c7c60432e38f92f778827f097bd7a92c1fb0295a65ed2dbe460b02091ec8c50a755ea01f
7
- data.tar.gz: 2038ec28c9e60db0513ddb454f1dd6bac325d12655228259a39fa4db8cd25f2f4739c05eb8a9faaa364593a0ec8000803f8f7e4447b8ae09054a1d4ab8b2fb37
6
+ metadata.gz: fb872109df5155820dbc63005e45afef0af5db00688f5bb69210166422e9a2c1233ae7a4e7cedf63c1f000fec75cddb057be51903daa7ba2309ce94ae4045526
7
+ data.tar.gz: dd047ceec3b6898e5488aefe6c131ce74b6136fbac8855c03c691c83cc16e83db692539df16bb02856e7a17066b76369dc6b0050cd0dff55be9de5b8f3238169
@@ -11,7 +11,22 @@ class ActionMailer::Base
11
11
  responses = original_collect_responses(*args, &block)
12
12
  md = ::Maildown::Md.new(responses)
13
13
  if md.contains_md?
14
- return md.to_responses
14
+ rendered_response = md.to_responses
15
+
16
+ if Maildown.enable_layouts
17
+ text = rendered_response[0]
18
+ html = rendered_response[1]
19
+
20
+ layout_name = _layout(text[:content_type])
21
+ text[:layout] = "#{layout_name}.text.erb"
22
+ text[:body] = render(text)
23
+
24
+ layout_name = _layout(html[:content_type])
25
+ html[:layout] = "#{layout_name}.html.erb"
26
+ html[:body] = render(html)
27
+ end
28
+
29
+ return rendered_response
15
30
  else
16
31
  return responses
17
32
  end
@@ -1,3 +1,3 @@
1
1
  module Maildown
2
- VERSION = "2.0.2"
2
+ VERSION = "2.0.3"
3
3
  end
data/lib/maildown.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  module Maildown
2
2
  @allow_indentations = false
3
+ @enable_layouts = false
3
4
 
4
5
  def self.allow_indentation
5
6
  @allow_indentations
@@ -8,6 +9,14 @@ module Maildown
8
9
  def self.allow_indentation=(allow_indentations)
9
10
  @allow_indentations = allow_indentations
10
11
  end
12
+
13
+ def self.enable_layouts
14
+ @enable_layouts
15
+ end
16
+
17
+ def self.enable_layouts=(enable_layouts)
18
+ @enable_layouts = enable_layouts
19
+ end
11
20
  end
12
21
 
13
22
  require 'maildown/markdown_engine'
@@ -0,0 +1,4 @@
1
+ class ApplicationMailer < ActionMailer::Base
2
+ default from: 'from@example.com'
3
+ end
4
+
@@ -0,0 +1,11 @@
1
+ class UserNoLayoutMailer < ApplicationMailer
2
+ layout false
3
+
4
+ def welcome
5
+ mail(
6
+ to: "foo@example.com",
7
+ reply_to: "noreply@schneems.com",
8
+ subject: "hello world"
9
+ )
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ class UserWithLayoutMailer < ApplicationMailer
2
+ layout "mail_layout"
3
+
4
+ def welcome
5
+ mail(
6
+ to: "foo@example.com",
7
+ reply_to: "noreply@schneems.com",
8
+ subject: "hello world"
9
+ )
10
+ end
11
+ end
@@ -0,0 +1 @@
1
+ HTML<%= yield %>
@@ -0,0 +1 @@
1
+ TEXT<%= yield %>
@@ -20,10 +20,10 @@ Dummy::Application.configure do
20
20
  config.active_support.deprecation = :log
21
21
 
22
22
  # Raise an error on page load if there are pending migrations
23
- config.active_record.migration_error = :page_load
23
+ # config.active_record.migration_error = :page_load
24
24
 
25
25
  # Debug mode disables concatenation and preprocessing of assets.
26
26
  # This option may cause significant delays in view rendering with a large
27
27
  # number of complex assets.
28
- config.assets.debug = true
28
+ # config.assets.debug = true
29
29
  end
File without changes