Best way to use html5 data attributes with rails content_tag helper?

前端 未结 6 748
清酒与你
清酒与你 2020-12-02 09:48

The issue, of course, is that ruby symbols don\'t like hyphens. So something like this obviously won\'t work:

content_tag(:div, \"Some Text\", :id => \"fo         


        
6条回答
  •  忘掉有多难
    2020-12-02 10:07

    Rails 3.1 ships with built-in helpers:

    http://api.rubyonrails.org/classes/ActionView/Helpers/TagHelper.html#method-i-tag

    E.g.,

    tag("div", :data => {:name => 'Stephen', :city_state => %w(Chicago IL)})
    # => 

提交回复
热议问题