Skip to content

Instantly share code, notes, and snippets.

@bobspryn
Created January 16, 2012 07:16
Show Gist options
  • Save bobspryn/1619542 to your computer and use it in GitHub Desktop.
Save bobspryn/1619542 to your computer and use it in GitHub Desktop.
An import filter that take @imports in files inline
class ImportFilter < Rake::Pipeline::Filter
def generate_output(inputs, output)
inputs.each do |input|
path = input.root + "/" + input.path.sub(/[^\/]+\.\w+/, "")
print "#{path}\n"
output.write input.read.gsub(/(@import\s+\"([^\"]+)\";)/) {
File.read("#{path}#{$2}")
}
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment