mirror of
https://github.com/haml/haml.git
synced 2022-11-09 12:33:31 -05:00
[Sass] Use the kept-around template text for error reporting.
This commit is contained in:
parent
80451b1e76
commit
5a111dd3e5
1 changed files with 4 additions and 16 deletions
|
@ -9,6 +9,7 @@ module Sass
|
||||||
# when it's used as a plugin for various frameworks.
|
# when it's used as a plugin for various frameworks.
|
||||||
# Currently Rails and Merb are supported out of the box.
|
# Currently Rails and Merb are supported out of the box.
|
||||||
module Plugin
|
module Plugin
|
||||||
|
include Haml::Util
|
||||||
extend self
|
extend self
|
||||||
|
|
||||||
@options = {
|
@options = {
|
||||||
|
@ -143,23 +144,10 @@ END
|
||||||
def header_string(e)
|
def header_string(e)
|
||||||
return "#{e.class}: #{e.message}" unless e.is_a? Sass::SyntaxError
|
return "#{e.class}: #{e.message}" unless e.is_a? Sass::SyntaxError
|
||||||
|
|
||||||
string = e.sass_backtrace_str
|
|
||||||
return string unless e.sass_filename && File.exists?(e.sass_filename)
|
|
||||||
|
|
||||||
string << "\n\n"
|
|
||||||
|
|
||||||
min = [e.sass_line - 5, 0].max
|
min = [e.sass_line - 5, 0].max
|
||||||
begin
|
e.sass_backtrace_str + "\n\n" +
|
||||||
File.read(e.sass_filename).rstrip.split("\n")[
|
enum_with_index(e.sass_template.rstrip.split("\n")[min .. e.sass_line + 5]).
|
||||||
min .. e.sass_line + 5
|
map {|line, i| "#{min + i + 1}: #{line}"}.join("\n")
|
||||||
].each_with_index do |line, i|
|
|
||||||
string << "#{min + i + 1}: #{line}\n"
|
|
||||||
end
|
|
||||||
rescue
|
|
||||||
string << "Couldn't read Sass file: #{e.sass_filename}"
|
|
||||||
end
|
|
||||||
|
|
||||||
string
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def template_filename(name, path)
|
def template_filename(name, path)
|
||||||
|
|
Loading…
Add table
Reference in a new issue