6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/hologram/code_example_renderer/factory.rb', line 6
def self.define(example_type, &block)
definition_proxy = DefinitionProxy.new
definition_proxy.instance_eval(&block)
example_class = Class.new(Example) do
if definition_proxy.rendered_example_block
define_method :rendered_example do
definition_proxy.rendered_example_block.call(code)
end
end
private
if definition_proxy.lexer_block
define_method :lexer do
definition_proxy.lexer_block.call
end
end
end
CodeExampleRenderer.register(example_type,
example_class: example_class,
example_template: Template.new(definition_proxy.example_template_name).template,
table_template: Template.new(definition_proxy.table_template_name).template,
)
end
|