Class: HomeworkReport::Renderer
- Inherits:
-
Object
- Object
- HomeworkReport::Renderer
- Defined in:
- lib/homework_report/renderer.rb
Instance Attribute Summary collapse
-
#scope ⇒ Object
Attributes.
Instance Method Summary collapse
-
#initialize(scope) ⇒ Renderer
constructor
Constructor.
-
#render(*args, &block) ⇒ Object
Render the template.
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
#scope ⇒ Object
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 = args. path = args.first inside_template(path) {|template| # clone scope object to prevent from overriding instance variables template.render(self.scope.clone, , &block) } end |