diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-03-14 14:58:34 -0300 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-03-14 14:58:34 -0300 |
commit | 274d5e45e00f6bddab8fecceccad3ba6c1c66232 (patch) | |
tree | 906e38aa4cbfb86dd3dcfa519d48bcd2c1853ffa /actionview/lib/action_view/template | |
parent | b4c96490eeb1fbb944e116c7703dd528b37fc08a (diff) | |
parent | 2c2326e6eab4d192e361871787335ffa711af597 (diff) | |
download | rails-274d5e45e00f6bddab8fecceccad3ba6c1c66232.tar.gz rails-274d5e45e00f6bddab8fecceccad3ba6c1c66232.tar.bz2 rails-274d5e45e00f6bddab8fecceccad3ba6c1c66232.zip |
Merge pull request #14329 from pch/digestor-lookup-fix
Ensure LookupContext in Digestor selects correct variant
Diffstat (limited to 'actionview/lib/action_view/template')
-rw-r--r-- | actionview/lib/action_view/template/resolver.rb | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/actionview/lib/action_view/template/resolver.rb b/actionview/lib/action_view/template/resolver.rb index 3a3b74cdd5..403824bd8e 100644 --- a/actionview/lib/action_view/template/resolver.rb +++ b/actionview/lib/action_view/template/resolver.rb @@ -154,7 +154,8 @@ module ActionView cached = nil templates.each do |t| t.locals = locals - t.formats = details[:formats] || [:html] if t.formats.empty? + t.formats = details[:formats] || [:html] if t.formats.empty? + t.variants = details[:variants] || [] if t.variants.empty? t.virtual_path ||= (cached ||= build_path(*path_info)) end end @@ -189,13 +190,15 @@ module ActionView } template_paths.map { |template| - handler, format = extract_handler_and_format(template, formats) - contents = File.binread template + handler, format, variant = extract_handler_and_format_and_variant(template, formats) + contents = File.binread(template) Template.new(contents, File.expand_path(template), handler, :virtual_path => path.virtual, :format => format, - :updated_at => mtime(template)) + :variant => variant, + :updated_at => mtime(template) + ) } end @@ -228,7 +231,7 @@ module ActionView # Extract handler and formats from path. If a format cannot be a found neither # from the path, or the handler, we should return the array of formats given # to the resolver. - def extract_handler_and_format(path, default_formats) + def extract_handler_and_format_and_variant(path, default_formats) pieces = File.basename(path).split(".") pieces.shift @@ -240,10 +243,10 @@ module ActionView end handler = Template.handler_for_extension(extension) - format = pieces.last && pieces.last.split(EXTENSIONS[:variants], 2).first # remove variant from format + format, variant = pieces.last.split(EXTENSIONS[:variants], 2) if pieces.last format &&= Template::Types[format] - [handler, format] + [handler, format, variant] end end |