[英]Rails is not rendering my HTML data attributes (RefineryCMS)
I have the following view refinery/portfolio/items/_item.html.erb
from RefineryCMS and for some reason my data-attributes are not being rendered into the DOM. 我有来自RefineryCMS的以下视图refinery/portfolio/items/_item.html.erb
,由于某种原因,我的数据属性未呈现到DOM中。
From my understanding it seems that RefineryCMS is potentially removing them? 根据我的理解,似乎RefineryCMS可能会删除它们?
Rails 4.2.6 and latest master branch of RefineryCMS Rails 4.2.6和RefineryCMS的最新主分支
Here is my ERB template: 这是我的ERB模板:
<li class="col-md-3 col-xs-6 thumb">
<a class="thumbnail" data-toggle="tab" data-target="#tab_<%= dom_id(item) %>">
<%= image_tag(item.image.url, {:title => item.title}) %>
</a>
</li>
Also tried: 还尝试了:
<li class="col-md-3 col-xs-6 thumb">
<%= link_to "", class: "thumbnail", data: { toggle: "tab", target: "#tab_#{dom_id(item)}" } do %>
<%= image_tag(item.image.url, {:title => item.title}) %>
<% end %>
</li>
It then renders HTML as: 然后将HTML呈现为:
<a class="thumbnail">
<img title="title" src="/img.png" alt="alt_title">
</a>
After visiting the RefineryCMS Gitter chat, I was able to get the assistance I needed. 在访问了RefineryCMS Gitter聊天之后,我能够获得所需的帮助。 The problem was recently in RefineryCMS 3 release they started sanitizing HTML data attributes. 问题是在最近的RefineryCMS 3版本中,他们开始清理HTML数据属性。
So I added the following configurations to my config/initializers/refinery/pages.rb
: 所以我在config/initializers/refinery/pages.rb
添加了以下配置:
config.layout_template_whitelist = ["application"]
config.add_whitelist_elements = %w[ source track ]
config.add_whitelist_attributes = %w[ kind srclang placeholder controls data-target data-toggle ]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.