Class: Lotus::View::Rendering::LayoutScope
- Inherits:
-
Object
- Object
- Lotus::View::Rendering::LayoutScope
- Defined in:
- lib/lotus/view/rendering/layout_scope.rb
Overview
Scope for layout rendering
Direct Known Subclasses
Instance Method Summary collapse
-
#format ⇒ Symbol
Returns the requested format.
-
#initialize(layout, scope) ⇒ LayoutScope
constructor
private
Initialize the scope.
-
#locals ⇒ Hash
The current locals.
-
#render(options) ⇒ String
Render a partial or a template within a layout template.
-
#view ⇒ Lotus::View
The current view.
Constructor Details
#initialize(layout, scope) ⇒ LayoutScope
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Initialize the scope
16 17 18 |
# File 'lib/lotus/view/rendering/layout_scope.rb', line 16 def initialize(layout, scope) @layout, @scope = layout, scope end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(m) ⇒ Object (protected)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Forward all the missing methods to the view scope or to the layout.
111 112 113 114 115 116 117 |
# File 'lib/lotus/view/rendering/layout_scope.rb', line 111 def method_missing(m) begin @scope.__send__ m rescue @layout.__send__ m end end |
Instance Method Details
#format ⇒ Symbol
Returns the requested format.
71 72 73 |
# File 'lib/lotus/view/rendering/layout_scope.rb', line 71 def format @scope.format end |
#locals ⇒ Hash
The current locals.
89 90 91 |
# File 'lib/lotus/view/rendering/layout_scope.rb', line 89 def locals @locals || @scope.locals end |
#render(options) ⇒ String
Render a partial or a template within a layout template.
62 63 64 |
# File 'lib/lotus/view/rendering/layout_scope.rb', line 62 def render() renderer().render end |
#view ⇒ Lotus::View
The current view.
80 81 82 |
# File 'lib/lotus/view/rendering/layout_scope.rb', line 80 def view @view || @scope.view end |