Class: Hiptest::Renderer
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
#walk_actionword, #walk_actionwords, #walk_call, #walk_dataset, #walk_folder, #walk_ifthen, #walk_item, #walk_libraries, #walk_libraryactionword, #walk_parameter, #walk_relative_item, #walk_scenario, #walk_scenarios, #walk_tag, #walk_template, #walk_test, #walk_tests
#walk_node
Constructor Details
#initialize(context) ⇒ Renderer
20
21
22
23
24
|
# File 'lib/hiptest-publisher/renderer.rb', line 20
def initialize(context)
@rendered = {}
@context = context
@template_finder = context.template_finder
end
|
Instance Attribute Details
#rendered ⇒ Object
Returns the value of attribute rendered.
8
9
10
|
# File 'lib/hiptest-publisher/renderer.rb', line 8
def rendered
@rendered
end
|
Class Method Details
.render(node, context) ⇒ Object
11
12
13
14
15
16
17
18
|
# File 'lib/hiptest-publisher/renderer.rb', line 11
def self.render(node, context)
renderer = self.new(context)
context.renderer_addons.each do |addon|
renderer.singleton_class.include(addon)
end
renderer.walk_node(node)
renderer.rendered[node]
end
|
Instance Method Details
#call_node_walker(node) ⇒ Object
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/hiptest-publisher/renderer.rb', line 26
def call_node_walker(node)
if node.is_a? Hiptest::Nodes::Node
@rendered_children = {}
node.children.each do |name, child|
@rendered_children[name] = @rendered[child]
@rendered_children[name].uniq! if name == :actionwords && @rendered_children[name].is_a?(Array)
end
@rendered[node] = render_node(node, super(node))
elsif node.is_a? Array
@rendered[node] = node.map {|item| @rendered[item]}
else
@rendered[node] = node
end
end
|
#render_node(node, render_context) ⇒ Object
43
44
45
46
47
48
49
50
|
# File 'lib/hiptest-publisher/renderer.rb', line 43
def render_node(node, render_context)
render_context ||= {}
render_context[:node] = node
render_context[:rendered_children] = @rendered_children
render_context[:context] = @context
@template_finder.get_compiled_handlebars(node.kind).call(render_context)
end
|