lib/lotus/view/dsl.rb in lotus-view-0.3.0 vs lib/lotus/view/dsl.rb in lotus-view-0.4.0
- old
+ new
@@ -210,16 +210,17 @@
@@template = value
end
end
# When a value is given, it specifies the layout.
+ # When false is given, Lotus::View::Rendering::NullLayout is returned.
# Otherwise, it returns the previously specified layout.
#
# When the global configuration is set (`Lotus::View.layout=`), after the
# loading process, it will return that layout if not otherwise specified.
#
- # @param value [Symbol,nil] the layout name
+ # @param value [Symbol, FalseClass, nil] the layout name
#
# @return [Symbol, nil] the specified layout for this view, if set
#
# @since 0.1.0
#
@@ -292,12 +293,31 @@
# Lotus::View.layout = :application
# Articles::Show.layout # => :articles
#
# Lotus::View.load!
# Articles::Show.layout # => :articles
+ #
+ # @example Disable layout for the view
+ # require 'lotus/view'
+ #
+ # class ApplicationLayout
+ # include Lotus::Layout
+ # end
+ #
+ # module Articles
+ # class Show
+ # include Lotus::View
+ # layout false
+ # end
+ # end
+ #
+ # Lotus::View.load!
+ # Articles::Show.layout # => Lotus::View::Rendering::NullLayout
def layout(value = nil)
if value.nil?
@_layout ||= Rendering::LayoutFinder.find(@layout || configuration.layout, configuration.namespace)
+ elsif !value
+ @layout = Lotus::View::Rendering::NullLayout
else
@layout = value
end
end