Class: Mbrao::Parser

Inherits:
Object
  • Object
show all
Includes:
ParserInterface, ParserValidations
Defined in:
lib/mbrao/parser.rb

Overview

A parser to handle pipelined content.

Instance Method Summary collapse

Instance Method Details

#parse(content, options = {}) ⇒ Content

Parses a source text.

Parameters:

  • content (Object)

    The content to parse.

  • options (Hash) (defaults to: {})

    A list of options for parsing.

Returns:



20
21
22
23
# File 'lib/mbrao/parser.rb', line 20

def parse(content, options = {})
  options = sanitize_parsing_options(options)
  ::Mbrao::Parser.create_engine(options[:engine]).parse(content, options)
end

#render(content, options = {}, context = {}) ⇒ String

Renders a content.

Parameters:

  • content (Content)

    The content to parse.

  • options (Hash) (defaults to: {})

    A list of options for renderer.

  • context (Hash) (defaults to: {})

    A context for rendering.

Returns:

  • (String)

    The rendered content.



31
32
33
34
# File 'lib/mbrao/parser.rb', line 31

def render(content, options = {}, context = {})
  options = sanitize_rendering_options(options)
  ::Mbrao::Parser.create_engine(options[:engine], :rendering).render(content, options, context)
end