Class: Volt::PathStringRenderer

Inherits:
Object
  • Object
show all
Defined in:
lib/volt/page/path_string_renderer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path, attrs = nil, page = nil, render_from_path = nil) ⇒ PathStringRenderer

Returns a new instance of PathStringRenderer.



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/volt/page/path_string_renderer.rb', line 12

def initialize(path, attrs=nil, page=nil, render_from_path=nil)
  # use the global page if one is not passed in
  page ||= $page

  # where to do the path lookup from
  render_from_path ||= "main/main/main/body"

  # Make path into a full path
  @view_lookup = Volt::ViewLookupForPath.new(page, render_from_path)
  full_path, controller_path = @view_lookup.path_for_template(path, nil)

  if full_path == nil
    raise ViewLookupException, "Unable to find view at `#{path}`"
  end

  controller_class, action = ControllerHandler.get_controller_and_action(controller_path)

  controller = controller_class.new#(SubContext.new(attrs, nil, true))
  controller.model = SubContext.new(attrs, nil, true)

  renderer = StringTemplateRenderer.new(page, controller, full_path)

  @html = renderer.html

  # remove when done
  renderer.remove
end

Instance Attribute Details

#htmlObject (readonly)

Returns the value of attribute html.



11
12
13
# File 'lib/volt/page/path_string_renderer.rb', line 11

def html
  @html
end