Class: RhetButler::HTMLGenerator::RenderFacade

Inherits:
Object
  • Object
show all
Defined in:
lib/rhet-butler/html-generator.rb

Instance Method Summary collapse

Constructor Details

#initialize(templates, item) ⇒ RenderFacade

Returns a new instance of RenderFacade.



17
18
19
20
# File 'lib/rhet-butler/html-generator.rb', line 17

def initialize(templates, item)
  @templates = templates
  @item = item
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &block) ⇒ Object



22
23
24
# File 'lib/rhet-butler/html-generator.rb', line 22

def method_missing(name, *args, &block)
  @item.__send__(name, *args, &block)
end

Instance Method Details

#render(path, item = nil, locals = nil) ⇒ Object



26
27
28
29
30
31
32
33
# File 'lib/rhet-butler/html-generator.rb', line 26

def render(path, item=nil, locals=nil)
  scope = if(item.nil?)
    self
  else
    self.class.new(@templates, item)
  end
  @templates.find(path).contents.render(scope || self, locals || {})
end