Sha256: 556ab565bce267837ee9946a2f7aee86181106962f5ebff88766f004ed51a9df

Contents?: true

Size: 1.22 KB

Versions: 27

Compression:

Stored size: 1.22 KB

Contents

module Hanami
  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 'hanami/view'
      #
      #   module Articles
      #     class Show
      #       include Hanami::View
      #       layout false
      #     end
      #   end
      #
      #   # In this scenario we will use a `NullLayout`.
      class NullLayout

        # Initialize a layout
        #
        # @param scope [Hanami::View::Rendering::Scope] view rendering scope
        # @param rendered [String] the output of the view rendering process
        #
        # @api private
        # @since 0.1.0
        #
        # @see Hanami::Layout#initialize
        # @see Hanami::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 Hanami::Layout#render
        # @see Hanami::View::Rendering#render
        def render
          @rendered
        end
      end
    end
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
hanami-view-1.0.0.rc1 lib/hanami/view/rendering/null_layout.rb
hanami-view-1.0.0.beta2 lib/hanami/view/rendering/null_layout.rb
hanami-view-1.0.0.beta1 lib/hanami/view/rendering/null_layout.rb
hanami-view-0.8.0 lib/hanami/view/rendering/null_layout.rb
hanami-view-0.7.0 lib/hanami/view/rendering/null_layout.rb
hanami-view-0.6.1 lib/hanami/view/rendering/null_layout.rb
hanami-view-0.6.0 lib/hanami/view/rendering/null_layout.rb