Method: Lotus::View::Configuration#layout

Defined in:
lib/lotus/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 `Lotus::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 'lotus/view'

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

Setting the value

require 'lotus/view'

Lotus::View.configure do
  layout :application
end

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

Setting the value in a namespaced app

require 'lotus/view'

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

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

Overloads:

  • #layout(value) ⇒ Object

    Sets the given value

    Parameters:

    • value (Symbol)

      the name of the layout

  • #layoutClass

    Gets the value

    Returns:

    • (Class)

See Also:

Since:

  • 0.2.0



238
239
240
241
242
243
244
# File 'lib/lotus/view/configuration.rb', line 238

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