noob , , . , , - :
class DynamicTemplateModel < ActiveRecord::Base
def self.parse_template(template, attrs={})
result = template
attrs.each { |field, value| result.gsub!("{{#{field}}}", value) }
result.gsub!(/\{\{\.w+\}\}/, '')
return result
end
end
: DynamicTemplate.parse_template(body, details)
details = {first_name: user.first_name, last_name: user.last_name, company: user&.company&.name, email_address: user.email}
body = "Hi {{first_name}} {{last_name}}, Your company {{company}} is registered with us successfully"
parse_template
, .
diofeher . .
, -. , .