Class: EmailTemplate
- Defined in:
- lib/app/models/email_template.rb
Overview
Support an email template for an account
Class Method Summary collapse
-
.copy_default(name) ⇒ Object
Copy the default from disk.
Instance Method Summary collapse
-
#htmlize_template ⇒ Object
Make sure the template is wrapped in html.
- #valid_liquid_template ⇒ Object
Methods included from StandardModel
#audit_action, #auto_strip_attributes, #capture_user_info, #clear_cache, #created_by_display_name, #delete_and_log, #destroy_and_log, included, #last_modified_by_display_name, #log_change, #log_deletion, #remove_blank_secure_fields, #save_and_log, #save_and_log!, #secure_fields, #update, #update!, #update_and_log, #update_and_log!
Methods included from App47Logger
clean_params, #clean_params, delete_parameter_keys, #log_controller_error, log_debug, #log_debug, log_error, #log_error, log_exception, #log_message, log_message, #log_warn, log_warn, mask_parameter_keys, #update_flash_messages
Class Method Details
.copy_default(name) ⇒ Object
Copy the default from disk
36 37 38 39 40 41 42 |
# File 'lib/app/models/email_template.rb', line 36 def self.copy_default(name) template = EmailTemplate.new template.name = name template.template = from_file name template.subject = from_file name, prefix: 'subject' template end |
Instance Method Details
#htmlize_template ⇒ Object
Make sure the template is wrapped in html
20 21 22 23 24 |
# File 'lib/app/models/email_template.rb', line 20 def htmlize_template if template.present? && !template.strip.start_with?("<") self.template = "<body><pre>#{template}</pre></body>" end end |
#valid_liquid_template ⇒ Object
26 27 28 29 30 31 |
# File 'lib/app/models/email_template.rb', line 26 def valid_liquid_template super && Liquid::Template.parse(self.subject).nil? rescue Exception => error self.errors.add(:subject, "Invalid liquid text in subject: #{error.}") false end |