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

前端 未结 6 746
清酒与你
清酒与你 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:16

    A helper's not a bad idea but seems a bit of an overkill for what's essentially me being fusy about syntax. I suppose there's nothing built into rails which is what I was hoping for. I'll just use this:

    content_tag(:div, "Some Text", :id => "foo", 'data-data_attr' => some_variable)
    

提交回复
热议问题