Class: Edison::Renderer
- Inherits:
-
Object
- Object
- Edison::Renderer
- Defined in:
- lib/edison.rb
Instance Attribute Summary collapse
-
#views ⇒ Object
Returns the value of attribute views.
Instance Method Summary collapse
-
#initialize(views) ⇒ Renderer
constructor
A new instance of Renderer.
- #render(view_name, data) ⇒ Object
Constructor Details
#initialize(views) ⇒ Renderer
Returns a new instance of Renderer.
72 73 74 |
# File 'lib/edison.rb', line 72 def initialize(views) self.views = views end |
Instance Attribute Details
#views ⇒ Object
Returns the value of attribute views.
71 72 73 |
# File 'lib/edison.rb', line 71 def views @views end |
Instance Method Details
#render(view_name, data) ⇒ Object
75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/edison.rb', line 75 def render(view_name, data) view = self.views[view_name] if view.nil? raise Exception, "Called for view #{view_name}, but _views/#{view_name} does not exist" end body = Mustache.render(view.body, data) if view.layout newdata = data.merge("yield" => body) self.render(view.layout, newdata) else body end end |