I'm a big HAML fan and I never ever encourage automatic HAML conversion. That said, I just converted a bunch of devise templates to HAML because ERB + form_helper gives me the irrits.
Never do this. But if you do, here's how: cd app/views/devise for i in `find . -name *.erb`; do html2haml $i > `dirname $i`/`basename -s .erb $i`.haml; done find . -name "*.erb" | xargs git rm git add . On Sat, Feb 25, 2012 at 1:57 PM, Craig Read <[email protected]> wrote: > Thanks for the feedback Gregory. > > I agree, I certainly wouldn't put the output into production without > vetting the code and running a test suite over it. > > A fair amount of my app is using scaffolded views, and I didn't find any > issues in those. > > One of the reasons why I created a version that could do a 'giv mv' is to > make it possible to revert the whole lot if I wasn't happy with the results. > When I did see the results, I was pleasantly surprised at how well > html2haml worked on my more complex views. > > The only thing I need/want to "fix" now is my helpers. > They're spitting out (poorly formatted) html, so I'm going to update them > to use the haml helper methods. > > Cheers, > > Craig. > > > On Sat, Feb 25, 2012 at 9:10 AM, Gregory McIntyre <[email protected]>wrote: > >> If I were you I'd code review all the HAML manually after that kind of >> thing. html2haml has in the past gotten things a little wrong >> occasionally in erb files with if statements and nesting - I can't >> remember specifics. >> >> The way I do this kind of thing is one file at a time and read over it >> to check. In Vim, I use something like :'<'>!html2haml (i.e. in visual >> mode, type :!html2haml<CR>) then :Gmove %<tab><C-W>haml<CR> to rename >> it. >> >> >> On 24 February 2012 01:11, Craig Read <[email protected]> wrote: >> > Hi, >> > >> > Pretty sure somebody has already created a more elegant way to do this >> (that >> > I don't know of). >> > I'm renowned for coming up with patents for disc-like objects with round >> > holes in the centre of them. ;) >> > >> > I wanted to convert all of my erb views to haml, but being lazy, I >> couldn't >> > be stuffed doing it file by file. >> > >> > I did find this snippet: http://snippets.dzone.com/posts/show/5449 >> > But it somehow felt dirty shoving a random script in the root of my >> rails >> > folder. >> > >> > So I rewrote it as a rake task. There is the original version, which >> > converts each erb file to a separate haml file. >> > I also wanted it to do a 'git mv' on each file, so butchered it a >> little to >> > do that. >> > >> > Hope it comes in handy for somebody. :) >> > >> > https://gist.github.com/1898581 >> > >> > Cheers, >> > -- >> > Craig Read >> > >> > @Catharz >> > https://github.com/Catharz >> > http://stackoverflow.com/users/158893/catharz >> > >> > -- >> > You received this message because you are subscribed to the Google >> Groups >> > "Ruby or Rails Oceania" group. >> > To post to this group, send email to [email protected]. >> > To unsubscribe from this group, send email to >> > [email protected]. >> > For more options, visit this group at >> > http://groups.google.com/group/rails-oceania?hl=en. >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Ruby or Rails Oceania" group. >> To post to this group, send email to [email protected]. >> To unsubscribe from this group, send email to >> [email protected]. >> For more options, visit this group at >> http://groups.google.com/group/rails-oceania?hl=en. >> >> > > > -- > Craig Read > > @Catharz > https://github.com/Catharz > http://stackoverflow.com/users/158893/catharz > > -- > You received this message because you are subscribed to the Google Groups > "Ruby or Rails Oceania" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/rails-oceania?hl=en. > -- Michael Pearson -- You received this message because you are subscribed to the Google Groups "Ruby or Rails Oceania" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rails-oceania?hl=en.
