diff options
Diffstat (limited to 'actionview/lib/action_view/template')
-rw-r--r-- | actionview/lib/action_view/template/error.rb | 21 | ||||
-rw-r--r-- | actionview/lib/action_view/template/handlers.rb | 2 | ||||
-rw-r--r-- | actionview/lib/action_view/template/handlers/erb.rb | 1 | ||||
-rw-r--r-- | actionview/lib/action_view/template/html.rb | 2 | ||||
-rw-r--r-- | actionview/lib/action_view/template/resolver.rb | 12 |
5 files changed, 10 insertions, 28 deletions
diff --git a/actionview/lib/action_view/template/error.rb b/actionview/lib/action_view/template/error.rb index d0ea03e228..7fc74a5502 100644 --- a/actionview/lib/action_view/template/error.rb +++ b/actionview/lib/action_view/template/error.rb @@ -81,8 +81,8 @@ module ActionView end end - def source_extract(indentation = 0, output = :console) - return unless num = line_number + def source_extract(indentation = 0) + return [] unless num = line_number num = num.to_i source_code = @template.source.split("\n") @@ -91,9 +91,9 @@ module ActionView end_on_line = [ num + SOURCE_CODE_RADIUS - 1, source_code.length].min indent = end_on_line.to_s.size + indentation - return unless source_code = source_code[start_on_line..end_on_line] + return [] unless source_code = source_code[start_on_line..end_on_line] - formatted_code_for(source_code, start_on_line, indent, output) + formatted_code_for(source_code, start_on_line, indent) end def sub_template_of(template_path) @@ -114,7 +114,6 @@ module ActionView end private - def source_location if line_number "on line ##{line_number} of " @@ -123,15 +122,11 @@ module ActionView end + file_name end - def formatted_code_for(source_code, line_counter, indent, output) - start_value = (output == :html) ? {} : [] - source_code.inject(start_value) do |result, line| + def formatted_code_for(source_code, line_counter, indent) + indent_template = "%#{indent}s: %s" + source_code.map do |line| line_counter += 1 - if output == :html - result.update(line_counter.to_s => "%#{indent}s %s\n" % ["", line]) - else - result << "%#{indent}s: %s" % [line_counter, line] - end + indent_template % [line_counter, line] end end end diff --git a/actionview/lib/action_view/template/handlers.rb b/actionview/lib/action_view/template/handlers.rb index 6450513003..c7ef456125 100644 --- a/actionview/lib/action_view/template/handlers.rb +++ b/actionview/lib/action_view/template/handlers.rb @@ -1,7 +1,5 @@ # frozen_string_literal: true -require "active_support/deprecation" - module ActionView #:nodoc: # = Action View Template Handlers class Template #:nodoc: diff --git a/actionview/lib/action_view/template/handlers/erb.rb b/actionview/lib/action_view/template/handlers/erb.rb index b6314a5bc3..69a5a0b1b9 100644 --- a/actionview/lib/action_view/template/handlers/erb.rb +++ b/actionview/lib/action_view/template/handlers/erb.rb @@ -63,7 +63,6 @@ module ActionView end private - def valid_encoding(string, encoding) # If a magic encoding comment was found, tag the # String with this encoding. This is for a case diff --git a/actionview/lib/action_view/template/html.rb b/actionview/lib/action_view/template/html.rb index ecd1c31e79..563bffd333 100644 --- a/actionview/lib/action_view/template/html.rb +++ b/actionview/lib/action_view/template/html.rb @@ -1,7 +1,5 @@ # frozen_string_literal: true -require "active_support/deprecation" - module ActionView #:nodoc: # = Action View HTML Template class Template #:nodoc: diff --git a/actionview/lib/action_view/template/resolver.rb b/actionview/lib/action_view/template/resolver.rb index ce53eb046d..bfac4c08a0 100644 --- a/actionview/lib/action_view/template/resolver.rb +++ b/actionview/lib/action_view/template/resolver.rb @@ -93,7 +93,6 @@ module ActionView end private - def canonical_no_templates(templates) templates.empty? ? NO_TEMPLATES : templates end @@ -130,7 +129,6 @@ module ActionView end private - def _find_all(name, prefix, partial, details, key, locals) find_templates(name, prefix, partial, details, locals) end @@ -183,7 +181,6 @@ module ActionView end private - def _find_all(name, prefix, partial, details, key, locals) path = Path.build(name, prefix, partial) query(path, details, details[:formats], locals, cache: !!key) @@ -282,12 +279,8 @@ module ActionView format, variant = pieces.last.split(EXTENSIONS[:variants], 2) if pieces.last format = if format Template::Types[format]&.ref - else - if handler.respond_to?(:default_format) # default_format can return nil - handler.default_format - else - nil - end + elsif handler.respond_to?(:default_format) # default_format can return nil + handler.default_format end # Template::Types[format] and handler.default_format can return nil @@ -323,7 +316,6 @@ module ActionView end private - def find_template_paths_from_details(path, details) # Instead of checking for every possible path, as our other globs would # do, scan the directory for files with the right prefix. |