Class: Shark::MailingService::Renderers::ErbRenderer

Inherits:
Object
  • Object
show all
Defined in:
lib/shark/mailing_service/renderers/erb_renderer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(template_folder) ⇒ ErbRenderer

Returns a new instance of ErbRenderer.



11
12
13
# File 'lib/shark/mailing_service/renderers/erb_renderer.rb', line 11

def initialize(template_folder)
  @template_folder = template_folder
end

Instance Attribute Details

#template_folderObject (readonly)

Returns the value of attribute template_folder.



9
10
11
# File 'lib/shark/mailing_service/renderers/erb_renderer.rb', line 9

def template_folder
  @template_folder
end

Instance Method Details

#render(template, format, locals = {}) ⇒ Object



15
16
17
18
19
# File 'lib/shark/mailing_service/renderers/erb_renderer.rb', line 15

def render(template, format, locals = {})
  template = load_template(template, format)
  context = build_context(format, locals)
  ::ERB.new(template).result(context.binding)
end