Sha256: 287f2176f39275261737d9899bdbed79fb90de99c5377ef90b0ae880cefde535

Contents?: true

Size: 740 Bytes

Versions: 9

Compression:

Stored size: 740 Bytes

Contents

desc "Converts everything to erb"
task :haml2erb do
  require 'httparty'

  FileUtils.mkdir_p "lib/templates/erb"

  Dir.glob( "**/*.haml").each do |f|
    puts "Converting #{f}"

    data = File.read( f )

    resp = HTTParty.post( "http://haml2erb.herokuapp.com/api.html", { query: { haml: data } } )

    puts "FROM--------"
    puts data
    puts "TO--------"
    puts resp.body

    outfile = f.gsub( /\.haml/, ".erb" )

    if outfile =~ /templates\/haml/
      outfile.gsub!( /templates\/haml/, "templates/erb" )
      puts "outfile = #{outfile}"

      FileUtils.mkdir_p( Pathname.new( outfile ).dirname )
    end

    File.open( outfile, "w" ) do |out|
      out.puts resp.body
    end

    FileUtils.mv( f, "#{f}.bak" )
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
happy_seed-0.0.21 lib/generators/happy_seed/base/templates/lib/tasks/haml2erb.rake
happy_seed-0.0.19 lib/generators/happy_seed/base/templates/lib/tasks/haml2erb.rake
happy_seed-0.0.18 lib/generators/happy_seed/base/templates/lib/tasks/haml2erb.rake
happy_seed-0.0.17 lib/generators/happy_seed/base/templates/lib/tasks/haml2erb.rake
happy_seed-0.0.16 lib/generators/happy_seed/base/templates/lib/tasks/haml2erb.rake
happy_seed-0.0.15 lib/generators/happy_seed/base/templates/lib/tasks/haml2erb.rake
happy_seed-0.0.14 lib/generators/happy_seed/base/templates/lib/tasks/haml2erb.rake
happy_seed-0.0.13 lib/generators/happy_seed/base/templates/lib/tasks/haml2erb.rake
happy_seed-0.0.12 lib/generators/happy_seed/base/templates/lib/tasks/haml2erb.rake