def run(content, params={})
imports = []
imports.concat(content.scan(/^@import\s+(["'])([^\1]+?)\1;/))
imports.concat(content.scan(/^@import\s+url\((["']?)([^)]+?)\1\);/))
imported_filenames = imports.map do |i|
i[1].match(/\.(less|css)$/) ? i[1] : i[1] + '.less'
end
imported_items = imported_filenames.map do |filename|
current_dir_pathname = Pathname.new(@item[:content_filename]).dirname.realpath
imported_pathname = Pathname.new(filename)
if imported_pathname.relative?
imported_pathname = current_dir_pathname + imported_pathname
end
next if !imported_pathname.exist?
imported_filename = imported_pathname.realpath
@items.find do |i|
next if i[:content_filename].nil?
Pathname.new(i[:content_filename]).realpath == imported_filename
end
end.compact
depend_on(imported_items)
paths = [ File.dirname(@item[:content_filename]) ]
parser = ::Less::Parser.new(:paths => paths)
parser.parse(content).to_css params
end