Module: SourceRoute::Formats::Html

Defined in:
lib/source_route/formats/html.rb

Class Method Summary collapse

Class Method Details

.slim_render(wrapper) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/source_route/formats/html.rb', line 8

def self.slim_render(wrapper)
  result_config = wrapper.condition.result_config
  template_path = File.expand_path "../html_semantic.slim", __FILE__
  slim_template = Slim::Template.new(template_path, pretty: true)

  filename = result_config[:filename] || "#{Time.now.strftime('%H')}-source-route.html"

  if result_config.import_return_to_call and wrapper.condition.has_call_and_return_event
    wrapper.result_builder.import_return_value_to_call_chain
    wrapper.result_builder.treeize_call_chain
  end
  # TODO: any exception triggered in render method will be absorb totally, how to fix it?
  html_output_str = slim_template.render(wrapper.result_builder)
  File.open(filename, 'w') do |f|
    f << html_output_str
  end
end