diff options
author | José Valim <jose.valim@gmail.com> | 2010-03-09 13:12:11 +0100 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-03-09 13:12:11 +0100 |
commit | 00d6271d2b11a14065925529af0c1200406f8beb (patch) | |
tree | e3024baa083ef39b97f0293da8661cb3744957ba /actionpack/lib/action_view/template | |
parent | c507e16dba844c7b066d145bfd5c5d23e7a9c5ad (diff) | |
download | rails-00d6271d2b11a14065925529af0c1200406f8beb.tar.gz rails-00d6271d2b11a14065925529af0c1200406f8beb.tar.bz2 rails-00d6271d2b11a14065925529af0c1200406f8beb.zip |
Clean up the API required from ActionView::Template.
Diffstat (limited to 'actionpack/lib/action_view/template')
-rw-r--r-- | actionpack/lib/action_view/template/resolver.rb | 31 | ||||
-rw-r--r-- | actionpack/lib/action_view/template/text.rb | 6 |
2 files changed, 13 insertions, 24 deletions
diff --git a/actionpack/lib/action_view/template/resolver.rb b/actionpack/lib/action_view/template/resolver.rb index 6e6c4c21ee..c43b357e9e 100644 --- a/actionpack/lib/action_view/template/resolver.rb +++ b/actionpack/lib/action_view/template/resolver.rb @@ -74,7 +74,7 @@ module ActionView def find_templates(name, prefix, partial, details) path = build_path(name, prefix, partial, details) - query(path, EXTENSION_ORDER.map { |ext| details[ext] }) + query(partial, path, EXTENSION_ORDER.map { |ext| details[ext] }) end def build_path(name, prefix, partial, details) @@ -84,34 +84,27 @@ module ActionView path end - def query(path, exts) + def query(partial, path, exts) query = File.join(@path, path) + exts.each do |ext| query << '{' << ext.map {|e| e && ".#{e}" }.join(',') << '}' end Dir[query].reject { |p| File.directory?(p) }.map do |p| - Template.new(File.read(p), File.expand_path(p), *path_to_details(p)) + handler, format = extract_handler_and_format(p) + Template.new(File.read(p), File.expand_path(p), handler, + :partial => partial, :virtual_path => path, :format => format) end end - # # TODO: fix me - # # :api: plugin - def path_to_details(path) - # [:erb, :format => :html, :locale => :en, :partial => true/false] - if m = path.match(%r'((^|.*/)(_)?[\w-]+)((?:\.[\w-]+)*)\.(\w+)$') - partial = m[3] == '_' - details = (m[4]||"").split('.').reject { |e| e.empty? } - handler = Template.handler_class_for_extension(m[5]) - - format = Mime[details.last] && details.pop.to_sym - locale = details.last && details.pop.to_sym + def extract_handler_and_format(path) + pieces = File.basename(path).split(".") + pieces.shift - virtual_path = (m[1].gsub("#{@path}/", "") << details.join(".")) - - return handler, :format => format, :locale => locale, :partial => partial, - :virtual_path => virtual_path - end + handler = Template.handler_class_for_extension(pieces.pop) + format = pieces.last && Mime[pieces.last] && pieces.pop.to_sym + [handler, format] end end diff --git a/actionpack/lib/action_view/template/text.rb b/actionpack/lib/action_view/template/text.rb index 5978a8a3ac..df394b0fb0 100644 --- a/actionpack/lib/action_view/template/text.rb +++ b/actionpack/lib/action_view/template/text.rb @@ -7,10 +7,6 @@ module ActionView #:nodoc: @content_type ||= Mime::TEXT end - def details - {:formats => [@content_type.to_sym]} - end - def identifier 'text template' end @@ -28,7 +24,7 @@ module ActionView #:nodoc: end def formats - [mime_type] + [@content_type.to_sym] end def partial? |