Method: Zero::Renderer#initialize

Defined in:
lib/zero/renderer.rb

#initialize(template_path, type_map = {}) ⇒ Renderer

initializes a new Renderer

This method takes a path to the base template directory and a type map. This type map is used to extend the possible renderings for different types, which the clients sends.

Examples:

create a simple renderer

Renderer.new('app/templates')

create a renderer with a small map

Renderer.new('app', {
  'html' => ['text/html', 'application/html+xml'],
  'json' => ['application/json', 'application/aweomse+json']
})

Parameters:

  • template_path (String)

    a string to templates

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

    a map of simple types to complex ones



36
37
38
39
# File 'lib/zero/renderer.rb', line 36

def initialize(template_path, type_map = {})
  @template_path = template_path + '/'
  @type_map = type_map
end