Class: TreeRb::ErbRender

Inherits:
Object
  • Object
show all
Includes:
ERB::Util
Defined in:
lib/tree_rb/output_plugins/html/erb_render.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(template_name, json_str) ⇒ ErbRender

Returns a new instance of ErbRender.



8
9
10
11
# File 'lib/tree_rb/output_plugins/html/erb_render.rb', line 8

def initialize(template_name, json_str)
  @template_name = template_name
  @json_str     = json_str
end

Instance Attribute Details

#json_strObject

Returns the value of attribute json_str.



6
7
8
# File 'lib/tree_rb/output_plugins/html/erb_render.rb', line 6

def json_str
  @json_str
end

Instance Method Details

#renderObject



13
14
15
16
17
# File 'lib/tree_rb/output_plugins/html/erb_render.rb', line 13

def render()
  template_file_name = File.join(File.dirname(__FILE__), "templates", @template_name)
  template = File.read(template_file_name)
  ERB.new(template).result(binding)
end