Sha256: 03cc01c31ee4a8bd323128ee68bfdacec19fa7795bdde000e511032419370032

Contents?: true

Size: 644 Bytes

Versions: 2

Compression:

Stored size: 644 Bytes

Contents

class HamlizeViews

  def initialize(path)
    @path = path
  end
  
  def convert!
    files = Dir["#{@path}/**/*.html.erb"]
    if files.empty?
      puts "No erb files found in directory '#{@path}'" 
      return 
    else
      puts
      files.each do |file|
        newfile = file.gsub(/\.erb$/, '.haml')
        puts "#{file} --> #{newfile}"
        `html2haml -r #{file} #{newfile}`
      end
      erb_files_path = "#{@path}/*.html.erb".gsub("//", "/")
      puts
      puts "Done! Be sure to check the new files for conversion flaws."
      puts "To get rid of the old view files: rm #{erb_files_path}"
      puts
    end
  end
  
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
zeke-hamlize_views-0.0.2 lib/hamlize_views.rb
zeke-hamlize_views-0.0.3 lib/hamlize_views.rb