how to prevent Refinery from deleteing custom tag attributes

193 views
Skip to first unread message

ma...@markproaudio.com

unread,
Jan 23, 2016, 5:52:45 PM1/23/16
to Refinery CMS
I see that Refinery will delete any non-standard attributes from html tags. Is there a way I can modify or prevent this behavior?

I use custom html attributes like toggle="someDivId" and some jQuery to toggle other elements in the page. Refinery prevents me from doing this.

Thanks,

Mark O.

ma...@markproaudio.com

unread,
Jan 23, 2016, 6:13:23 PM1/23/16
to Refinery CMS
Refinery also converts <i> to <em>. I understand that it's trying to be smart and convert the deprecated italics tag to the new standard emphasis tag, but this totally messes up Font Awesome icons. Any way to stop this unwanted intelligence?

Anita Graham

unread,
Jan 27, 2016, 4:34:26 AM1/27/16
to Refinery CMS
It is wymeditor (Refinery's default HTML/wysiwig editor) which does these conversions.
There are settings you can change to accept more tags:

in config/iniitializers/refinery/core.rb you can write (for instance)

  # Add extra tags to the wymeditor whitelist e.g. = {'tag' => {'attributes' => {'1' => 'href'}}} or just {'tag' => {}}
  # config.wymeditor_whitelist_tags =  {'span' => {
    # 'attributes' => {
      # '1' => 'data-tooltip'
    # }}}
  config.wymeditor_whitelist_tags = {
  'video' => {
    'attributes' => {
      '1' => 'width',
      '2' => 'height',
      '3' => 'poster'
    }
  },
  'source' => {
    'attributes' => {
      '1' => 'src',
      '2' => 'type'
    }
  }
}

This example shows setting a tag and some element attributes.

I use FontAwesome, as does the refinery backend. However, I tend to set a class on the element then add the font-awesome icons via matching css.
Or just match some elements that I want to add icons to.

e.g.
>li {
  @include icon(green, 'check');
 }

which will add the check icon, in green to the list elements that match. (size and padding have default values).


Anita Graham

unread,
Jan 27, 2016, 4:36:10 AM1/27/16
to Refinery CMS
Oh...as wymeditor has now been split into a separate gem (refinerycms-wymeditor), these settings may have to be done in the gem settings.

ma...@markproaudio.com

unread,
Jan 27, 2016, 11:41:56 AM1/27/16
to Refinery CMS
Thanks Anita. I'll give that code a try. I made it work without custom attributes, but it's nice to have the freedom to do what I want.

I got around the font-awesome issue by just using span tags instead of i tags.

ekonotek

unread,
Jan 28, 2016, 2:23:13 PM1/28/16
to Refinery CMS
Anita, thanks for the post, I've been struggling to get this to work, 

Now, where do I find/change the "gem settings"? I've installed Refinery 3.0.1

Again, thank you in advance,

Anita Graham

unread,
Feb 1, 2016, 9:59:20 PM2/1/16
to Refinery CMS
Try this:

Refinery::Wymeditor.configure do |config|
  # Add extra tags to the wymeditor whitelist e.g. = {'tag' => {'attributes': '1': 'href'}} or just {'tag' => {}}
  # config.whitelist_tags = <%= Refinery::Wymeditor.whitelist_tags.inspect %>
end


In config/initializers/refinery/wymeditor.rb
Reply all
Reply to author
Forward
0 new messages