| Class | ActionView::Template |
| In: |
vendor/rails/actionpack/lib/action_view/template.rb
|
| Parent: | Object |
| base_path | [RW] | |
| extension | [RW] | |
| filename | [RW] | |
| format | [RW] | |
| load_path | [RW] | |
| name | [RW] |
# File vendor/rails/actionpack/lib/action_view/template.rb, line 12
12: def initialize(template_path, load_paths = [])
13: template_path = template_path.dup
14: @base_path, @name, @format, @extension = split(template_path)
15: @base_path.to_s.gsub!(/\/$/, '') # Push to split method
16: @load_path, @filename = find_full_path(template_path, load_paths)
17:
18: # Extend with partial super powers
19: extend RenderablePartial if @name =~ /^_/
20: end
# File vendor/rails/actionpack/lib/action_view/template.rb, line 31
31: def content_type
32: format.gsub('.', '/')
33: end
# File vendor/rails/actionpack/lib/action_view/template.rb, line 22
22: def format_and_extension
23: (extensions = [format, extension].compact.join(".")).blank? ? nil : extensions
24: end
# File vendor/rails/actionpack/lib/action_view/template.rb, line 67
67: def method_segment
68: relative_path.to_s.gsub(/([^a-zA-Z0-9_])/) { $1.ord }
69: end
# File vendor/rails/actionpack/lib/action_view/template.rb, line 35
35: def mime_type
36: Mime::Type.lookup_by_extension(format) if format
37: end
# File vendor/rails/actionpack/lib/action_view/template.rb, line 27
27: def multipart?
28: format && format.include?('.')
29: end
# File vendor/rails/actionpack/lib/action_view/template.rb, line 40
40: def path
41: [base_path, [name, format, extension].compact.join('.')].compact.join('/')
42: end
# File vendor/rails/actionpack/lib/action_view/template.rb, line 45
45: def path_without_extension
46: [base_path, [name, format].compact.join('.')].compact.join('/')
47: end
# File vendor/rails/actionpack/lib/action_view/template.rb, line 50
50: def path_without_format_and_extension
51: [base_path, name].compact.join('/')
52: end
# File vendor/rails/actionpack/lib/action_view/template.rb, line 55
55: def relative_path
56: path = File.expand_path(filename)
57: path.sub!(/^#{Regexp.escape(File.expand_path(RAILS_ROOT))}\//, '') if defined?(RAILS_ROOT)
58: path
59: end
# File vendor/rails/actionpack/lib/action_view/template.rb, line 72
72: def render_template(view, local_assigns = {})
73: render(view, local_assigns)
74: rescue Exception => e
75: raise e unless filename
76: if TemplateError === e
77: e.sub_template_of(self)
78: raise e
79: else
80: raise TemplateError.new(self, view.assigns, e)
81: end
82: end