Sha256: 683dbb95b73328d857c2cad14e6efb951a4061a822f9a06e2bdb943c9454dba8

Contents?: true

Size: 1.21 KB

Versions: 6

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 nil
      #     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

6 entries across 6 versions & 1 rubygems

Version Path
lotus-view-0.4.2 lib/lotus/view/rendering/null_layout.rb
lotus-view-0.4.1 lib/lotus/view/rendering/null_layout.rb
lotus-view-0.4.0 lib/lotus/view/rendering/null_layout.rb
lotus-view-0.3.0 lib/lotus/view/rendering/null_layout.rb
lotus-view-0.2.0 lib/lotus/view/rendering/null_layout.rb
lotus-view-0.1.0 lib/lotus/view/rendering/null_layout.rb