Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save nikolaiwarner/808920 to your computer and use it in GitHub Desktop.
Save nikolaiwarner/808920 to your computer and use it in GitHub Desktop.
Thor scripts for bulk converting files to haml and sass
# 2011 Nikolai Warner <n@nikolaiwarner.com>
# Originally inspired by divoxx at http://snippets.dzone.com/posts/show/5449
class ConvertAll < Thor
desc "to_haml [path]", "convert all erb files to haml in [path]"
def to_haml(path='.')
delete_when_done = yes?("Remove erb files after conversion? (y/n): ")
Dir["#{path}/**/*.erb"].each do |file|
`html2haml -rx #{file} #{file.gsub(/\.erb$/, '.haml')}`
`rm #{file}` if delete_when_done
end
end
desc "to_sass [path]", "convert all css files to sass in [path]"
def to_sass(path='.')
Dir["#{path}/**/*.css"].each do |file|
`sass-convert #{file} #{file.gsub(/\.css$/, '.sass')}`
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment