Module: Hanami::Layout
- Defined in:
- lib/hanami/layout.rb
Overview
Layout
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
-
.included(base) ⇒ Object
private
Register a layout.
Instance Method Summary collapse
-
#initialize(scope, rendered) ⇒ Object
private
Initialize a layout.
-
#local(key) ⇒ Object, Hanami::View::Rendering::NullLocal
It tries to invoke a method for the view or a local for the given key.
-
#render ⇒ String
private
Render the layout.
Class Method Details
.included(base) ⇒ Object
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.
Register a layout
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/hanami/layout.rb', line 24 def self.included(base) conf = Hanami::View::Configuration.for(base) conf.add_layout(base) base.class_eval do extend Hanami::View::Dsl.dup extend ClassMethods include Utils::ClassAttribute class_attribute :configuration self.configuration = conf.duplicate end conf.copy!(base) end |
Instance Method Details
#initialize(scope, rendered) ⇒ Object
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 a layout
126 127 128 |
# File 'lib/hanami/layout.rb', line 126 def initialize(scope, rendered) @scope, @rendered = View::Rendering::LayoutScope.new(self, scope), rendered end |
#local(key) ⇒ Object, Hanami::View::Rendering::NullLocal
It tries to invoke a method for the view or a local for the given key. If the lookup fails, it returns a null object.
159 160 161 |
# File 'lib/hanami/layout.rb', line 159 def local(key) @scope.local(key) end |
#render ⇒ String
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.
Render the layout
138 139 140 |
# File 'lib/hanami/layout.rb', line 138 def render template.render(@scope, &Proc.new{@rendered}) end |