how to convert html or erb to haml in vim

I use HAML a lot, it’s a very nice templating language. And I copy a lot of html/erb snippets to my haml views. Here is how you can configure vim to convert your html to haml.

1) Install the html2haml gem. If you are using rvm, generate a wrapper using the code below.

1
2
rvm wrapper ruby-1.9.2-p290 vim html2haml

2) Add the following mapping to your ~/.vimrc

1
2
3
" html2haml
:vmap <leader>h :!/home/minhajuddin/.rvm/bin/vim_html2haml<cr>

That’s it, now you can select a block of text and hit the <leader>h command to convert your html/erb to haml. You need to make sure that the paths and the rvm strings correspond to your machine settings to get this working, also html2haml needs a few more gems. Check html2haml for more info


I am currently working on Zammu which makes Automatic Deployment of static websites to Github Pages very easy. I would love to get your feedback on it, Use the invitation code KHAJA