Class: Template

Inherits:
Object
  • Object
show all
Includes:
StandardModel
Defined in:
lib/app/models/template.rb

Overview

Base template object for managing all communications templates

Direct Known Subclasses

EmailTemplate, NotificationTemplate

Class Method Summary collapse

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

.from_file(template_name, format: 'liquid', prefix: nil, delivery_channel: 'email') ⇒ Object

Retrieve the template out of the project



26
27
28
29
30
31
32
33
34
35
# File 'lib/app/models/template.rb', line 26

def self.from_file(template_name, format: 'liquid', prefix: nil, delivery_channel: 'email')
  file_name = [template_name, prefix, format].compact.join('.')
  if File.exist?(Rails.root.join('lib/templates', delivery_channel, file_name))
    File.open(Rails.root.join('lib/templates', delivery_channel, file_name))
  else
    File.open(File.join(__dir__, '../../../lib/templates', delivery_channel, file_name))
  end.read
rescue StandardError
  nil
end