Sha256: d4065cd6f7084a53fd00b75bc6a00bcdb5beeb00be96623f647036267f7df572

Contents?: true

Size: 1.21 KB

Versions: 3

Compression:

Stored size: 1.21 KB

Contents

module Lotus
  module View
    module Rendering
      # Null Object pattern for Layout.
      # It's used when a view doesn't require a layout.
      #
      # @api private
      # @since 0.1.0
      #
      # @example
      #   require 'lotus/view'
      #
      #   module Articles
      #     class Show
      #       include Lotus::View
      #       layout false
      #     end
      #   end
      #
      #   # In this scenario we will use a `NullLayout`.
      class NullLayout

        # Initialize a layout
        #
        # @param scope [Lotus::View::Rendering::Scope] view rendering scope
        # @param rendered [String] the output of the view rendering process
        #
        # @api private
        # @since 0.1.0
        #
        # @see Lotus::Layout#initialize
        # @see Lotus::View::Rendering#render
        def initialize(scope, rendered)
          @rendered = rendered
        end

        # Render the layout
        #
        # @return [String] the output of the rendering process
        #
        # @api private
        # @since 0.1.0
        #
        # @see Lotus::Layout#render
        # @see Lotus::View::Rendering#render
        def render
          @rendered
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
lotus-view-0.5.0 lib/lotus/view/rendering/null_layout.rb
lotus-view-0.4.4 lib/lotus/view/rendering/null_layout.rb
lotus-view-0.4.3 lib/lotus/view/rendering/null_layout.rb