Sha256: cc0f4ed6f6cd535c6135a7b302c0d5ea5687c6b32be0063d9118f26941b0edf0

Contents?: true

Size: 1.02 KB

Versions: 2

Compression:

Stored size: 1.02 KB

Contents

require File.join(File.dirname(__FILE__), 'base')
module Mack
  module Rendering # :nodoc:
    module Type # :nodoc:
      # Used to render files stored in the public directory. These files are NOT run through any engines
      # and are returned 'as is'.
      class Public < Mack::Rendering::Type::Base
        
        # Attempts to find the file on disk and return it. If no file extension is provided then the 'format' 
        # of the request is appended to the file name.
        def render
          p_file = self.render_value
          if File.extname(p_file).blank?
            p_file = "#{p_file}.#{self.options[:format]}"
          end
          find_file(Mack::Configuration.public_directory, p_file) do |f|
            return File.open(f).read
          end
          raise Mack::Errors::ResourceNotFound.new(p_file)
        end
        
        # No layouts should be used with this Mack::Rendering::Type
        def allow_layout?
          false
        end
        
      end # Public
    end # Type
  end # Rendering
end # Mack

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mack-0.5.5.3 lib/rendering/type/public.rb
mack-0.5.5.4 lib/rendering/type/public.rb