Created
July 22, 2010 17:26
-
-
Save jacqui/486285 to your computer and use it in GitHub Desktop.
convert haml templates into erb using the w2tags gem
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'w2tags' | |
require File.join(File.dirname(__FILE__), '..', 'config', 'environment') | |
W2 = W2Tags::Parser.new('rails') | |
templates = Dir.glob("#{RAILS_ROOT}/app/views/**/*.haml") | |
puts "converting #{templates.size} to erb :(" | |
templates.each do |template| | |
haml_data = File.read(template) | |
erb = W2.parse_line("%initialize\n"<<haml_data).join | |
erb_template = File.new(template.gsub('haml', 'erb'), "w+") | |
erb_template.puts(erb) | |
erb_template.close | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Note that w2tags doesn't seem to add an "<% end %>" tag at the close of blocks, so you'll have to go through and find where those are missing.