Skip to content

Instantly share code, notes, and snippets.

@johnagan
Last active December 20, 2015 11:19
Show Gist options
  • Save johnagan/6122437 to your computer and use it in GitHub Desktop.
Save johnagan/6122437 to your computer and use it in GitHub Desktop.
HTML2Slim
require 'html2slim'
html_path = ""
slim_path = ""
Dir.mkdir(slim_path) unless File.exists?(slim_path)
Dir["#{html_path}/*.html"].each do |file_name|
html = File.read(file_name).encode('UTF-8', 'binary', invalid: :replace, undef: :replace, replace: '')
File.open("#{slim_path}/#{File.basename(file_name)}.slim", 'w') do |f|
f.write HTML2Slim.convert!(html, :html)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment