Sha256: ce2e6eda33b81fb91af6d76011517c32d8b9d7ae9c9d27792fd26e7420a92dbd

Contents?: true

Size: 769 Bytes

Versions: 5

Compression:

Stored size: 769 Bytes

Contents

module BetterErrors
  # @private
  class CodeFormatter::HTML < CodeFormatter
    def source_unavailable
      "<p class='unavailable'>Source is not available</p>"
    end

    def formatted_lines
      each_line_of(highlighted_lines) { |highlight, current_line, str|
        class_name = highlight ? "highlight" : ""
        sprintf '<pre class="%s">%s</pre>', class_name, str
      }
    end
    
    def formatted_nums
      each_line_of(highlighted_lines) { |highlight, current_line, str|
        class_name = highlight ? "highlight" : ""
        sprintf '<span class="%s">%5d</span>', class_name, current_line
      }
    end

    def formatted_code
      %{<div class="code_linenums">#{formatted_nums.join}</div><div class="code">#{super}</div>}
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
better_errors-2.0.0 lib/better_errors/code_formatter/html.rb
better_errors-1.1.0 lib/better_errors/code_formatter/html.rb
better_errors-1.0.1 lib/better_errors/code_formatter/html.rb
better_errors-1.0.0 lib/better_errors/code_formatter/html.rb
better_errors-1.0.0.rc1 lib/better_errors/code_formatter/html.rb