Flowdock
method

source_extract

Importance_0
v2.3.8 - Show latest stable - 0 notes - Class: ActionView::TemplateError
source_extract(indentation = 0) public

No documentation

This method has no description. You can help the Ruby on Rails community by adding new notes.

Hide source
# File actionpack/lib/action_view/template_error.rb, line 39
    def source_extract(indentation = 0)
      return unless num = line_number
      num = num.to_i

      source_code = @template.source.split("\n")

      start_on_line = [ num - SOURCE_CODE_RADIUS - 1, 0 ].max
      end_on_line   = [ num + SOURCE_CODE_RADIUS - 1, source_code.length].min

      indent = ' ' * indentation
      line_counter = start_on_line
      return unless source_code = source_code[start_on_line..end_on_line]

      source_code.sum do |line|
        line_counter += 1
        "#{indent}#{line_counter}: #{line}\n"
      end
    end
Register or log in to add new notes.