Easily convert your Rails .erb files to .haml files
2009 March 2
With rails there currently isn’t a way to generate haml template files instead of erb template files when generating a controller. If there is, news to me and please post in comments as I would love to know. I know this exists in Merb so this feature will probably come along with Rails 3 I would hope.
What I do is setup an alias within my bash profile so that I can call “hamlit” on the directory in question. My alias command refers to the following code.
for f in *.erb; do mv $f `basename $f .erb`.haml;done; After this alias is setup I CD into my views directory in question and run "hamlit" and I now have haml templates instead of erb for rails. This function just renames the files so if you have content in there that you would like to save it will still be in there. The code obviously needs to be updated to haml template code and not erb though. <div class="zemanta-pixie"><img class="zemanta-pixie-img" src="http://img.zemanta.com/pixy.gif?x-id=8d9104c8-7223-4c70-b731-04146a125823" alt="" /></div>
No comments yet
