Parent

Included Modules

Class/Module Index [+]

Quicksearch

ActionView::Template

Attributes

base_path[RW]
extension[RW]
filename[W]
format[RW]
load_path[RW]
locale[RW]
name[RW]
template_path[RW]

Public Class Methods

exempt_from_layout(*extensions) click to toggle source

Don’t render layouts for templates with the given extensions.

# File lib/action_view/template.rb, line 104
def self.exempt_from_layout(*extensions)
  regexps = extensions.collect do |extension|
    extension.is_a?(Regexp) ? extension : /\.#{Regexp.escape(extension.to_s)}$/
  end
  @@exempt_from_layout.merge(regexps)
end
new(template_path, load_path = nil) click to toggle source
# File lib/action_view/template.rb, line 116
def initialize(template_path, load_path = nil)
  @template_path, @load_path = template_path.dup, load_path
  @base_path, @name, @locale, @format, @extension = split(template_path)
  @base_path.to_s.gsub!(/\/$/, '') # Push to split method

  # Extend with partial super powers
  extend RenderablePartial if @name =~ /^_/
end

Public Instance Methods

accessible_paths() click to toggle source
# File lib/action_view/template.rb, line 125
def accessible_paths
  paths = []

  if valid_extension?(extension)
    paths << path
    paths << path_without_extension
    if multipart?
      formats = format.split(".")
      paths << "#{path_without_format_and_extension}.#{formats.first}"
      paths << "#{path_without_format_and_extension}.#{formats.second}"
    end
  else
    # template without explicit template handler should only be reachable through its exact path
    paths << template_path
  end

  paths
end
content_type() click to toggle source
# File lib/action_view/template.rb, line 153
def content_type
  format.gsub('.', '/')
end
exempt_from_layout?() click to toggle source
# File lib/action_view/template.rb, line 184
def exempt_from_layout?
  @@exempt_from_layout.any? { |exempted| path =~ exempted }
end
filename() click to toggle source
# File lib/action_view/template.rb, line 188
def filename
  # no load_path means this is an "absolute pathed" template
  load_path ? File.join(load_path, template_path) : template_path
end
format_and_extension() click to toggle source
# File lib/action_view/template.rb, line 144
def format_and_extension
  (extensions = [format, extension].compact.join(".")).blank? ? nil : extensions
end
load!() click to toggle source
# File lib/action_view/template.rb, line 216
def load!
  freeze
end
method_segment() click to toggle source
# File lib/action_view/template.rb, line 199
def method_segment
  relative_path.to_s.gsub(/([^a-zA-Z0-9_])/) { $1.ord }
end
mime_type() click to toggle source
# File lib/action_view/template.rb, line 157
def mime_type
  Mime::Type.lookup_by_extension(format) if format && defined?(::Mime)
end
multipart?() click to toggle source
# File lib/action_view/template.rb, line 149
def multipart?
  format && format.include?('.')
end
path() click to toggle source
# File lib/action_view/template.rb, line 162
def path
  [base_path, [name, locale, format, extension].compact.join('.')].compact.join('/')
end
path_without_extension() click to toggle source
# File lib/action_view/template.rb, line 167
def path_without_extension
  [base_path, [name, locale, format].compact.join('.')].compact.join('/')
end
path_without_format_and_extension() click to toggle source
# File lib/action_view/template.rb, line 172
def path_without_format_and_extension
  [base_path, [name, locale].compact.join('.')].compact.join('/')
end
relative_path() click to toggle source
# File lib/action_view/template.rb, line 177
def relative_path
  path = File.expand_path(filename)
  path.sub!(/^#{Regexp.escape(File.expand_path(RAILS_ROOT))}\//, '') if defined?(RAILS_ROOT)
  path
end
render_template(view, local_assigns = {}) click to toggle source
# File lib/action_view/template.rb, line 204
def render_template(view, local_assigns = {})
  render(view, local_assigns)
rescue Exception => e
  raise e unless filename
  if TemplateError === e
    e.sub_template_of(self)
    raise e
  else
    raise TemplateError.new(self, view.assigns, e)
  end
end
source() click to toggle source
# File lib/action_view/template.rb, line 194
def source
  File.read(filename)
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.