Module: EmailTemplateHelper
- Extended by:
- ActiveSupport::Concern
- Defined in:
- app/helpers/email_template_helper.rb
Instance Method Summary collapse
- #email_message_body_text(&block) ⇒ Object
- #email_message_button(&block) ⇒ Object
- #email_message_section(&block) ⇒ Object
- #email_message_small_text(&block) ⇒ Object
- #email_message_spacer(count = 1) ⇒ Object
-
#method_missing(method_name, *args, &block) ⇒ Object
Ok, some madness ahead.
- #respond_to_missing?(method_name, include_private = false) ⇒ Boolean
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block) ⇒ Object
Ok, some madness ahead. There seems to be a bug in rails as documented www.candland.net/2012/04/17/rails-routes-used-in-an-isolated-engine/ where including the URL helpers will cause all other path helpers to go crazy. So instead of include Rails.application.routes.url_helpers we specifically respond to path and url helpers in the method_missing and proxy them up to the main_app if they exist. This way the email helpers in the devise templates will still work.
10 11 12 13 14 15 16 |
# File 'app/helpers/email_template_helper.rb', line 10 def method_missing(method_name, *args, &block) if method_name.to_s.end_with?('_path', '_url') main_app.send(method_name, *args) else super end end |
Instance Method Details
#email_message_body_text(&block) ⇒ Object
30 31 32 |
# File 'app/helpers/email_template_helper.rb', line 30 def (&block) content_tag(:span, capture(&block), style: "font-family: Avenir, 'Helvetica Neue', Helvetica, sans-serif; font-size:28px; color:#444444;") end |
#email_message_button(&block) ⇒ Object
38 39 40 41 42 43 44 45 46 47 |
# File 'app/helpers/email_template_helper.rb', line 38 def (&block) content_tag(:table, border: 0, cellpadding: 0, cellspacing: 0, width: '50%', style: 'background-color:#16A086;') do content_tag(:tr) do concat((4)) concat(content_tag(:td, nil, style: "padding: 18px 20px 18px 20px; font-family: Avenir, 'Helvetica Neue', Helvetica, sans-serif, sans-serif; color: #ffffff; font-size: 18px; text-align: center;") do content_tag(:span, capture(&block), style: 'text-decoration: none; color: #ffffff;') end) end end end |
#email_message_section(&block) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'app/helpers/email_template_helper.rb', line 49 def (&block) content_tag(:tr) do content_tag(:td) do content_tag(:table, border: 0, cellpadding: 0, cellspacing: 0, width: '100%') do content_tag(:tr) do content_tag(:td, align: 'center', valign: 'top') do content_tag(:table, border: 0, cellpadding: 10, cellspacing: 0, width: '100%') do content_tag(:tr) do content_tag(:td, capture(&block), align: 'center', valign: 'top') end end end end end end end end |
#email_message_small_text(&block) ⇒ Object
34 35 36 |
# File 'app/helpers/email_template_helper.rb', line 34 def (&block) content_tag(:span, capture(&block), style: "font-family: Avenir, 'Helvetica Neue', Helvetica, sans-serif; font-size:22px; color:#444444;") end |
#email_message_spacer(count = 1) ⇒ Object
22 23 24 25 26 27 28 |
# File 'app/helpers/email_template_helper.rb', line 22 def (count = 1) (1..count).each do return capture do concat content_tag(:br) end end end |
#respond_to_missing?(method_name, include_private = false) ⇒ Boolean
18 19 20 |
# File 'app/helpers/email_template_helper.rb', line 18 def respond_to_missing?(method_name, include_private = false) method_name.to_s.end_with?('_path', '_url') || super end |