Class: Racket::ViewManager

Inherits:
Object
  • Object
show all
Defined in:
lib/racket/view_manager.rb

Overview

Handles rendering in Racket applications.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(locator, renderer) ⇒ ViewManager

Returns a new instance of ViewManager.



30
31
32
33
# File 'lib/racket/view_manager.rb', line 30

def initialize(locator, renderer)
  @locator = locator
  @renderer = renderer
end

Class Method Details

.service(_options = {}) ⇒ Proc

Returns a service proc that can be used by the registry.

Parameters:

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

    (unused)

Returns:

  • (Proc)


26
27
28
# File 'lib/racket/view_manager.rb', line 26

def self.service(_options = {})
  ->(reg) { new(reg.template_locator, reg.template_renderer) }
end

Instance Method Details

#render(controller) ⇒ Hash

Renders a controller based on the request path and the variables set in the controller instance.

Parameters:

Returns:

  • (Hash)


40
41
42
# File 'lib/racket/view_manager.rb', line 40

def render(controller)
  @renderer.render(controller, *get_view_and_layout(controller))
end