A little refactoring in sass/plugin.
git-svn-id: svn://hamptoncatlin.com/haml/trunk@595 7063305b-7217-0410-af8c-cdc13e5119b9
This commit is contained in:
parent
b7cf2063b4
commit
6e2c784c6a
|
@ -51,9 +51,28 @@ module Sass
|
|||
l_options[:filename] = filename
|
||||
l_options[:load_paths] = (l_options[:load_paths] || []) + [l_options[:template_location]]
|
||||
engine = Engine.new(File.read(filename), l_options)
|
||||
begin
|
||||
result = engine.render
|
||||
result = begin
|
||||
engine.render
|
||||
rescue Exception => e
|
||||
exception_string(e)
|
||||
end
|
||||
|
||||
# Create any directories that might be necessary
|
||||
dirs = [l_options[:css_location]]
|
||||
name.split("/")[0...-1].each { |dir| dirs << "#{dirs[-1]}/#{dir}" }
|
||||
dirs.each { |dir| Dir.mkdir(dir) unless File.exist?(dir) }
|
||||
|
||||
# Finally, write the file
|
||||
File.open(css, 'w') do |file|
|
||||
file.print(result)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def exception_string(e)
|
||||
if RAILS_ENV != "production"
|
||||
e_string = "#{e.class}: #{e.message}"
|
||||
|
||||
|
@ -75,27 +94,12 @@ module Sass
|
|||
end
|
||||
end
|
||||
end
|
||||
result = "/*\n#{e_string}\n\nBacktrace:\n#{e.backtrace.join("\n")}\n*/"
|
||||
"/*\n#{e_string}\n\nBacktrace:\n#{e.backtrace.join("\n")}\n*/"
|
||||
else
|
||||
result = "/* Internal stylesheet error */"
|
||||
"/* Internal stylesheet error */"
|
||||
end
|
||||
end
|
||||
|
||||
# Create any directories that might be necessary
|
||||
dirs = [l_options[:css_location]]
|
||||
name.split("/")[0...-1].each { |dir| dirs << "#{dirs[-1]}/#{dir}" }
|
||||
dirs.each { |dir| Dir.mkdir(dir) unless File.exist?(dir) }
|
||||
|
||||
# Finally, write the file
|
||||
File.open(css, 'w') do |file|
|
||||
file.print(result)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def template_filename(name)
|
||||
"#{@@options[:template_location]}/#{name}.sass"
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue