Class: HomeworkReport::Renderer

Inherits:
Object
  • Object
show all
Defined in:
lib/homework_report/renderer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(scope) ⇒ Renderer

Constructor



8
9
10
# File 'lib/homework_report/renderer.rb', line 8

def initialize(scope)
  self.scope = scope
end

Instance Attribute Details

#scopeObject

Attributes



5
6
7
# File 'lib/homework_report/renderer.rb', line 5

def scope
  @scope
end

Instance Method Details

#render(*args, &block) ⇒ Object

Render the template

Usage #1: s.render FILE [OPTIONS] { BLOCK }



16
17
18
19
20
21
22
23
24
25
# File 'lib/homework_report/renderer.rb', line 16

def render(*args, &block)
  args = args.flatten
  options = args.extract_options!
  path = args.first
  
  inside_template(path) {|template|
    # clone scope object to prevent from overriding instance variables
    template.render(self.scope.clone, options, &block)
  }
end