views:

145

answers:

4

Hi i converting rails views from erb to Haml .The issue i faced is when use the form_for the haml throws the UNEXPECTED $end error. I am sure i did the space indentation well with in form_for .......Even if i use "each do" loop is says the same error. if i revert the haml to erb it works fine.

Rails version i used : 2.3.2 & i installed haml gem 2.2.19 as well as haml plugin also.

my controller code :

def new
    @user = User.new
end

My View code :

.contentContainer.signup
 - form_for(@user) do |f|
+2  A: 

Make sure your haml indentation is perfect.

.contentContainer.signup
  - form_for(@user) do |f|
    = f.text_field :name
Jonathan Julian
yes i did the indentation perfectly but even if use each do loop it says me the same error .
palani
If that's not an indictment on HAML, I don't know what is.
Toby Hede
You need to edit and paste your entire Haml template in the question.
Jonathan Julian
Fewer, cleaner lines with indentation ... vs. more, noisier lines with symbols?
Justice
A: 

Are you including - end in your templates? Haml takes care of ends for you, so if you add your own, it won't work.

Can you paste your entire template (in a code block, so it's formatted properly)?

nex3
A: 

If the last line in file is indented there has to be an addidtional, empty line.

arnvald
I don't think this is true.
Jeremy Weiskotten
A: 

There's also a good command-line tool to make transition easier: html2haml. It doesn't always produce the prettiest haml, but it certainly works.

Hey, there's even a web-based form for this: http://html2haml.heroku.com/

Generally, be sure your indentation is perfect. haml is very particular about indentation. If you use a decent editor (such as textmate or vim) this is an easy task.

joshsz