开发者

Issue with Haml files

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
    开发者_JAVA技巧@user = User.new
end

My View code :

.contentContainer.signup
 - form_for(@user) do |f|


Make sure your haml indentation is perfect.

.contentContainer.signup
  - form_for(@user) do |f|
    = f.text_field :name


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)?


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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜