Class: LiquidDiagrams::BasicBlock Abstract
- Inherits:
-
Liquid::Block
- Object
- Liquid::Block
- LiquidDiagrams::BasicBlock
- Defined in:
- lib/liquid_diagrams/basic_block.rb
Overview
This class is abstract.
Subclass and override #render_content to implement
Class Method Summary collapse
-
.renderer ⇒ Object
Return the renderer class matching the block.
Instance Method Summary collapse
- #handle_error(error) ⇒ Object
- #read_config ⇒ Object private
- #render(context) ⇒ Object
- #render_content ⇒ Object
Class Method Details
.renderer ⇒ Object
Return the renderer class matching the block
7 8 9 10 11 |
# File 'lib/liquid_diagrams/basic_block.rb', line 7 def self.renderer @renderer ||= Renderers.const_get( name.split('::').last.gsub(/Block$/, 'Renderer') ) end |
Instance Method Details
#handle_error(error) ⇒ Object
28 29 30 |
# File 'lib/liquid_diagrams/basic_block.rb', line 28 def handle_error(error) error end |
#read_config ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
33 34 35 36 37 38 |
# File 'lib/liquid_diagrams/basic_block.rb', line 33 def read_config = LiquidDiagrams.configuration(parse_context, key: block_name) = Utils.(@markup.strip) .merge() end |
#render(context) ⇒ Object
Note:
Do not override this method, override #render_content instead
14 15 16 17 18 19 20 |
# File 'lib/liquid_diagrams/basic_block.rb', line 14 def render(context) @context = context @content = super.to_s @config = read_config render_content end |
#render_content ⇒ Object
22 23 24 25 26 |
# File 'lib/liquid_diagrams/basic_block.rb', line 22 def render_content self.class.renderer.render(@content, @config) rescue Errors::BasicError => error handle_error(error) end |