Class: Rundoc::CodeCommand::PrintERB
Constant Summary
NEWLINE, RUNDOC_DEFAULT_ERB_BINDING, RUNDOC_ERB_BINDINGS
Instance Attribute Summary
#command, #contents, #keyword, #original_args, #render_command, #render_result
Instance Method Summary
collapse
#hidden?, #not_hidden?, #push
Constructor Details
#initialize(line = nil, binding: RUNDOC_DEFAULT_ERB_BINDING) ⇒ PrintERB
Returns a new instance of PrintERB.
Instance Method Details
#call(env = {}) ⇒ Object
35
36
37
38
39
40
41
|
# File 'lib/rundoc/code_command/print/erb.rb', line 35
def call(env = {})
if render_before?
""
else
render
end
end
|
#render ⇒ Object
31
32
33
|
# File 'lib/rundoc/code_command/print/erb.rb', line 31
def render
@render ||= ERB.new([@line, contents].compact.join("\n")).result(@binding)
end
|
#render_before? ⇒ Boolean
43
44
45
|
# File 'lib/rundoc/code_command/print/erb.rb', line 43
def render_before?
!render_command? && render_result?
end
|
#to_md(env) ⇒ Object
23
24
25
26
27
28
29
|
# File 'lib/rundoc/code_command/print/erb.rb', line 23
def to_md(env)
if render_before?
env[:before] << render
end
""
end
|