Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Haml "Illegal Nesting" problem; how to place multiple code elements in the same tag?

- @subjects.each do |s|
  %tr
  %td= s.position
  %td= s.name
  %td= s.visible ? "Yes" : "No"
  %td= s.pages.size
  %td= link_to("Show", {:action => "show", :id => s.id}, :class => "action show") 
    = link_to("Edit", {:action => "edit", :id => s.id}, :class => "action edit")
    = link_to("Delete", {:action => "delete", :id => s.id}, :class => "action delete")

error_msg:

Illegal nesting: content can't be both given on the same line as %td and nested within it.

I want those three links--show, edit, and delete--in the same td; how can I do it?

like image 785
Hugh Avatar asked Apr 24 '11 12:04

Hugh


1 Answers

You just need to change this:

%td= link_to("Show", {:action => "show", :id => s.id}, :class => "action show") 
  = link_to("Edit", {:action => "edit", :id => s.id}, :class => "action edit")
  = link_to("Delete", {:action => "delete", :id => s.id}, :class => "action delete")

to this:

%td
  = link_to("Show", {:action => "show", :id => s.id}, :class => "action show") 
  = link_to("Edit", {:action => "edit", :id => s.id}, :class => "action edit")
  = link_to("Delete", {:action => "delete", :id => s.id}, :class => "action delete")

You should also indent the tds from the tr.

like image 141
matt Avatar answered Oct 21 '22 12:10

matt