Class: Mbrao::Parser

Inherits:
Object
  • Object
show all
Includes:
PublicInterface, Validations
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:


173
174
175
176
# File 'lib/mbrao/parser.rb', line 173

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.


184
185
186
187
# File 'lib/mbrao/parser.rb', line 184

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