Method: Hanami::View::Configuration#layout

Defined in:
lib/hanami/view/configuration.rb

#layout(value) ⇒ Object #layoutClass

Set the global layout

If not set, this value defaults to `nil`, while at the rendering time it will use `Hanami::View::Rendering::NullLayout`.

This is part of a DSL, for this reason when this method is called with an argument, it will set the corresponding instance variable. When called without, it will return the already set value, or the default.

Examples:

Getting the value

require 'hanami/view'

Hanami::View.configuration.layout # => nil

Setting the value

require 'hanami/view'

Hanami::View.configure do
  layout :application
end

Hanami::View.configuration.layout # => ApplicationLayout

Setting the value in a namespaced app

require 'hanami/view'

module MyApp
  View = Hanami::View.duplicate(self) do
    layout :application
  end
end

MyApp::View.configuration.layout # => MyApp::ApplicationLayout

Overloads:

  • #layout(value) ⇒ Object

    Sets the given value

  • #layoutClass

    Gets the value

See Also:

Since:

  • 0.2.0


240
241
242
243
244
245
246
# File 'lib/hanami/view/configuration.rb', line 240

def layout(value = nil)
  if value.nil?
    Rendering::LayoutFinder.find(@layout, @namespace)
  else
    @layout = value
  end
end