Class: Rundoc::CodeCommand::PreErb
Constant Summary
NEWLINE, RUNDOC_DEFAULT_ERB_BINDING, RUNDOC_ERB_BINDINGS
Instance Attribute Summary
#contents, #keyword, #original_args, #render_command, #render_result
Instance Method Summary
collapse
#hidden?, #not_hidden?, #push
Constructor Details
#initialize(line) ⇒ PreErb
Returns a new instance of PreErb.
5
6
7
8
9
10
11
12
13
14
15
16
|
# File 'lib/rundoc/code_command/pre/erb.rb', line 5
def initialize(line)
@line = line
@binding = RUNDOC_ERB_BINDINGS[RUNDOC_DEFAULT_ERB_BINDING]
@code = nil
@command = nil
@template = nil
@render_delegate_result = nil
@render_delegate_command = nil
@render_result = false
@render_command = false
end
|
Instance Method Details
#call(env = {}) ⇒ Object
54
55
56
57
58
59
60
|
# File 'lib/rundoc/code_command/pre/erb.rb', line 54
def call(env = {})
delegate = command
env[:stack].push(delegate)
""
end
|
#code ⇒ Object
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
# File 'lib/rundoc/code_command/pre/erb.rb', line 27
def code
@code ||= begin
vis = +""
vis += @render_delegate_command ? ">" : "-"
vis += @render_delegate_result ? ">" : "-"
code = [@line, @contents]
.compact
.reject(&:empty?)
.join("\n")
@template = ":::#{vis} #{code}"
puts "pre.erb: Applying ERB, template:\n#{@template}"
result = ERB.new(@template).result(@binding)
puts "pre.erb: ERB result:\n#{result}"
puts "pre.erb: done, ready to delegate"
result
end
end
|
#render_command=(value) ⇒ Object
23
24
25
|
# File 'lib/rundoc/code_command/pre/erb.rb', line 23
def render_command=(value)
@render_delegate_command = value
end
|
#render_result=(value) ⇒ Object
Visibility is injected by the parser, capture it and pass it to the delegate
19
20
21
|
# File 'lib/rundoc/code_command/pre/erb.rb', line 19
def render_result=(value)
@render_delegate_result = value
end
|
#to_md(env = {}) ⇒ Object
50
51
52
|
# File 'lib/rundoc/code_command/pre/erb.rb', line 50
def to_md(env = {})
""
end
|