Can't you just pull the "fields_for" call outside the %tr? "fields_for"
doesn't actually output anything, so as long as you're careful with your 'a'
and 'b' objects, you should be fine.

...I think.

:brad

On Thu, Jan 28, 2010 at 3:41 PM, John Wells <[email protected]> wrote:

> Guys,
>
> I ran across something today I'm not sure haml can handle, and I'd
> really appreciate any guidance you can offer me.
>
> We're converting our erb over to haml and enjoying it so far. However,
> we have a form that places fields within the same td into to different
> contexts with fields_for. Additionally, follow on tds are in the
> second context. So, in erb, it looks like this:
>
> <% form_for @obj do |a| %>
> <table>
>  <tr>
>    <td>
>       <%= a.label :name %>
>       <%= a.text_field :name %>
>       <% fields_for :address, @address do |b| %>
>         <%= b.label :street %>
>         <%= b.text_field :street %>
>   </td>
>   <td>
>     <%= b.label :city %>
>     <%= b.text_field :city %>
>   </td>
>  </tr>
> </table>
>  <% end %>
> <% end %>
>
> This example is very contrived and not the real example, but you get
> the idea. Translated to haml, this becomes:
>
> - form_for @obj do |a|
>  %table
>    %tr
>      %td
>        = a.label :name
>        = a.text_field :name
>        - fields_for :address, @address do |b|
>          = b.label :street
>          = b.text_field :street
>      %td
>        = b.label :city
>        = b.text_field :city
>
> See the problem? Introducing a block within a %td, that should really
> transcend %tds breaks haml's assumptions here, I think. If I indent
> the second %td to be within the - fields_for block, haml thinks it's a
> td nested within a td. It's not.
>
> I'm not sure this is even possible in haml, although I think there are
> occasionally valid reasons to do this.
>
> Can anyone help?
>
> Thanks!
> John
>
> --
> You received this message because you are subscribed to the Google Groups
> "Haml" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected] <haml%[email protected]>.
> For more options, visit this group at
> http://groups.google.com/group/haml?hl=en.
>
>


-- 
Bradley Grzesiak
co-founder, bendyworks llc
http://bendyworks.com/

-- 
You received this message because you are subscribed to the Google Groups 
"Haml" 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/haml?hl=en.

Reply via email to