Rails- nested content_tag

前端 未结 4 1853
执笔经年
执笔经年 2020-12-02 07:38

I\'m trying to nest content tags into a custom helper, to create something like this:

&l
4条回答
  •  栀梦
    栀梦 (楼主)
    2020-12-02 08:16

    You need a + to quick fix :D

    module InputHelper
      def editable_input(label,name)
        content_tag :div, :class => "field" do
          content_tag(:label,label) + # Note the + in this line
          text_field_tag(name,'', :class => 'medium new_value')
        end
      end
    end
    
    <%= editable_input 'Year Founded', 'companyStartDate' %>
    

    Inside the block of content_tag :div, only the last returned string would be displayed.

提交回复
热议问题