Class: Rory::Renderer::Context

Inherits:
Object
  • Object
show all
Includes:
PathGeneration
Defined in:
lib/rory/renderer/context.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from PathGeneration

#path_to

Constructor Details

#initialize(options = {}) ⇒ Context

Returns a new instance of Context.



9
10
11
12
13
14
15
# File 'lib/rory/renderer/context.rb', line 9

def initialize(options = {})
  (options[:locals] || {}).each do |key, value|
    singleton_class.send(:define_method, key) { value }
  end
  @app = options[:app]
  @base_path = options[:base_path]
end

Instance Attribute Details

#base_pathObject (readonly)

Returns the value of attribute base_path.



7
8
9
# File 'lib/rory/renderer/context.rb', line 7

def base_path
  @base_path
end

Instance Method Details

#get_bindingObject



17
18
19
# File 'lib/rory/renderer/context.rb', line 17

def get_binding
  binding
end

#render(template_name, opts = {}) ⇒ Object



21
22
23
24
25
# File 'lib/rory/renderer/context.rb', line 21

def render(template_name, opts = {})
  opts = { :layout => false, :app => @app, :base_path => @base_path }.merge(opts)
  renderer = Rory::Renderer.new(template_name, opts)
  renderer.render
end