Class: Cadenza::TextRenderer

Inherits:
BaseRenderer show all
Defined in:
lib/cadenza/text_renderer.rb

Overview

The TextRenderer is the standard rendering logic for Cadenza. It will render an AST according to the rules specified in the Cadenza manual. See the manual for details.

Instance Attribute Summary

Attributes inherited from BaseRenderer

#output

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseRenderer

#initialize

Constructor Details

This class inherits a constructor from Cadenza::BaseRenderer

Class Method Details

.render(document_node, context) ⇒ Object

Renders the document given with the given context directly to a string returns.

Parameters:

  • document_node (DocumentNode)

    the root of the AST you want to render.

  • context (Context)

    the context object to render the document with



13
14
15
16
17
# File 'lib/cadenza/text_renderer.rb', line 13

def self.render(document_node, context)
   io = StringIO.new
   new(io).render(document_node, context)
   io.string
end

Instance Method Details

#render(node, context, blocks = {}) ⇒ Object



19
20
21
22
23
# File 'lib/cadenza/text_renderer.rb', line 19

def render(node, context, blocks={})
   passed_blocks = blocks.is_a?(BlockHierarchy) ? blocks : BlockHierarchy.new(blocks)

   super(node, context, passed_blocks)
end