0

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.

From my understanding it seems that RefineryCMS is potentially removing them?

Rails 4.2.6 and latest master branch of RefineryCMS

Here is my ERB template:

<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:

<a class="thumbnail">
  <img title="title" src="/img.png" alt="alt_title">
</a>
arinh
  • 206
  • 1
  • 12
  • Is that the raw HTML output or the DOM from the inspector? I highly doubt that refinery is modifying it - especially the former example where you are printing straight to the ERB template. While it is possible to manipulate the "buffer" before it is actually sent its seldom a good idea as its just a huge string. – max May 14 '16 at 14:32
  • 1
    Also if you want create a `A` tag without a URL its probably better to use `content_tag :a, class: "thumbnail", data: { toggle: "tab", target: "#tab_" + dom_id(item) } do` – max May 14 '16 at 14:37

1 Answers1

0

After visiting the RefineryCMS Gitter chat, I was able to get the assistance I needed. The problem was recently in RefineryCMS 3 release they started sanitizing HTML data attributes.

So I added the following configurations to my 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 ]
arinh
  • 206
  • 1
  • 12