views:

52

answers:

2

I have this in one of my haml views:

-form_for :news_item_comment, :url=>{:id => comment.id, :controller => 'comment' , :action => 'add_comment'}, :html => {:id => "form-#{comment.id}"}  do |f|    
   ...

Since it's really long and hard to read I want to split it over 2 lines. Is there anyway to do this without violating haml's whitespace rules?

A: 

In earlier versions of haml there was no way to multi-line a single statement - something which I was frustrated with in the same way you are as it made templates way harder to read in some cases.

In theory there is a multi-line syntax for handling statements with lots of attributes. I have not tried to use it - but it's worth a shot, if that doesn't work then it is likely still the case that you cannot multi-line that type of statement.

paulthenerd
A: 

Yes, there is multiline syntax. However, it's encouraged that you move your long lines into helper methods rather than use it, as that will make your templates more readable in the long run.

nex3