Class: Chaplin::Responses::Page

Inherits:
Struct
  • Object
show all
Defined in:
lib/chaplin/responses/page.rb

Overview

data is a hash with symbols as keys and api endpoints or other pages as values

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#dataObject

Returns the value of attribute data

Returns:

  • (Object)

    the current value of data



7
8
9
# File 'lib/chaplin/responses/page.rb', line 7

def data
  @data
end

#template_pathObject

Returns the value of attribute template_path

Returns:

  • (Object)

    the current value of template_path



7
8
9
# File 'lib/chaplin/responses/page.rb', line 7

def template_path
  @template_path
end

Instance Method Details

#execute(request_params, sinatra_server) ⇒ Object



9
10
11
# File 'lib/chaplin/responses/page.rb', line 9

def execute(request_params, sinatra_server)
  render(request_params)
end

#render(request_params) ⇒ Object



13
14
15
16
17
# File 'lib/chaplin/responses/page.rb', line 13

def render(request_params)
  page = Mustache.new
  page.template_file = template_path
  page.render(rendered_data(request_params).merge({params: request_params}))
end