module ActionMailer::Markdown::TemplateHandler
Constants
- OBJECT_ATTRIBUTE_MATCHER
- UNDERSCORE
Public Class Methods
expand_variables(template, variables)
click to toggle source
# File lib/action_mailer/markdown/template_handler.rb, line 15 def self.expand_variables(template, variables) template .scan(OBJECT_ATTRIBUTE_MATCHER) .map(&:first) .each_with_object(variables) do |match, buffer| target, attribute = match.split(".") buffer[match.to_sym] = variables[target.to_sym].public_send(attribute) end end
extract_variables(context)
click to toggle source
# File lib/action_mailer/markdown/template_handler.rb, line 25 def self.extract_variables(context) context .instance_variable_get(:@_assigns) .each_with_object({}) do |(name, value), buffer| next if name.start_with?(UNDERSCORE) buffer[name.to_sym] = value end end
render(template, context, format)
click to toggle source
# File lib/action_mailer/markdown/template_handler.rb, line 9 def self.render(template, context, format) variables = expand_variables(template, extract_variables(context)) source = template.rstrip % variables ActionMailer::Markdown.public_send(format, source) end