Sha256: 3440e79644b7603430dbb37c045cc8734aedd29e76fe351a030f694432c9b6d8

Contents?: true

Size: 886 Bytes

Versions: 21

Compression:

Stored size: 886 Bytes

Contents

require 'hanami/views/default_template_finder'

module Hanami
  # @api private
  module Views
    # The default view that is rendered for non successful responses (200 and 201)
    #
    # @since 0.1.0
    # @api private
    class Default
      include Hanami::View

      configuration.reset!

      layout nil
      root Pathname.new(File.dirname(__FILE__)).join('../templates').realpath
      template 'default'

      # @api private
      def title
        "#{response[0]} - #{response[2].first || Http::Status.message_for(response[0])}"
      end

      # @api private
      def self.render(root, template_name, context)
        format   = context[:format]
        template = DefaultTemplateFinder.new(self, root, template_name, format).find

        if template
          new(template, context).render
        else
          super(context)
        end
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
hanami-1.3.5 lib/hanami/views/default.rb
hanami-1.3.4 lib/hanami/views/default.rb
hanami-1.3.3 lib/hanami/views/default.rb
hanami-1.3.2 lib/hanami/views/default.rb
hanami-1.3.1 lib/hanami/views/default.rb
hanami-1.3.0 lib/hanami/views/default.rb
hanami-1.3.0.beta1 lib/hanami/views/default.rb
hanami-1.2.0 lib/hanami/views/default.rb
hanami-1.2.0.rc2 lib/hanami/views/default.rb
hanami-1.2.0.rc1 lib/hanami/views/default.rb
hanami-1.2.0.beta2 lib/hanami/views/default.rb
hanami-1.2.0.beta1 lib/hanami/views/default.rb
hanami-1.1.1 lib/hanami/views/default.rb
hanami-1.1.0 lib/hanami/views/default.rb
hanami-1.1.0.rc1 lib/hanami/views/default.rb
hanami-1.1.0.beta3 lib/hanami/views/default.rb
hanami-1.1.0.beta2 lib/hanami/views/default.rb
hanami-1.1.0.beta1 lib/hanami/views/default.rb
hanami-1.0.0 lib/hanami/views/default.rb
hanami-1.0.0.rc1 lib/hanami/views/default.rb