Skip to content

Instantly share code, notes, and snippets.

@johnagan

johnagan/html2slim.rb

Last active Dec 20, 2015
Embed
What would you like to do?
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