2010-10-29 39 views

回答

1
def entry_template 
    content_tag(:div, :class => "item_title") do 
     "<h3>" + 
     if x == 'garage' 
     entry.garage.name 
     else 
     'Not garage' 
     end + 
     "</h3>" 
    end 
end 

,或者在我的眼睛有點更好,因爲它不切換風格的時候,

def entry_template 
    content_tag(:div, :class => "item_title") do 
     content_tag(:h3) do 
     if x == 'garage' 
      entry.garage.name 
     else 
      'Not garage' 
     end 
     end 
    end 
end