Class: Hologram::BlockCodeRenderer
- Inherits:
-
Object
- Object
- Hologram::BlockCodeRenderer
- Defined in:
- lib/hologram/block_code_renderer.rb
Instance Method Summary collapse
-
#initialize(code, markdown_language) ⇒ BlockCodeRenderer
constructor
A new instance of BlockCodeRenderer.
- #render ⇒ Object
Constructor Details
#initialize(code, markdown_language) ⇒ BlockCodeRenderer
Returns a new instance of BlockCodeRenderer.
5 6 7 8 |
# File 'lib/hologram/block_code_renderer.rb', line 5 def initialize(code, markdown_language) @code = code @markdown_language = markdown_language end |
Instance Method Details
#render ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'lib/hologram/block_code_renderer.rb', line 10 def render if is_table? && table_template examples = code.split("\n\n").map { |code_snippet| example_class.new(code_snippet) } ERB.new(table_template).result(binding) else example = example_class.new(code) ERB.new(example_template).result(example.get_binding) end end |