Adding custom data attributes rails image tag

后端 未结 2 715
闹比i
闹比i 2021-02-05 06:35

I need to add data-description and data-title for galleria in my rails application but I can\'t see how to do this with the image tag. So far I have this:



        
相关标签:
2条回答
  • 2021-02-05 06:55

    As of rails 5.1, this syntax should work:

    <%= image_tag entry.filename, title: "title", class: "class", data: {description: entry.caption, title: entry.caption} %>
    

    Read more about attributes you can include in your image_tag under examples: rails api docs.

    0 讨论(0)
  • 2021-02-05 06:56

    The correct syntax for this is

    <%= image_tag entry.filename, :title => "title", :class => "class", :data => { :description => entry.caption, :title => entry.caption }  %>
    
    0 讨论(0)
提交回复
热议问题