spree / deface

Rails plugin that allows you to customize ERB views in a Rails application without editing the underlying view.
MIT License
517 stars 128 forks source link

Deface removing data attributes in Haml templates #196

Closed meowsus closed 4 years ago

meowsus commented 5 years ago

I started talking about this on #172 but figured that it might be best to open a new issue, since the problem described in the original ticket differs from what I'm seeing.

What I am seeing is if a Haml view in my application contains a data attribute formatted as follows:

.component{ data: { foo_bar: 'baz' } }

When I try to "deface" this view, I am left with:

<div class='component'>

So Deface (or Nokogiri) is gobbling up my data attributes.

I've confirmed that this form in the original template will work:

.component{ 'data-foo-bar' => 'baz' }

Possible points of interest:

  1. My project is a meta gem, which contains 3 engines:
    • One responsible for an administration panel
    • One responsible for a user facing interface
    • One responsible for the common abstractions between the two, this is where our dependencies are managed
  2. I'm including Deface as part of an external engine, or plugin, to my app.
  3. My app is:
    • Using nokogiri 1.10.3
    • Using rails 5.2.3
    • Using haml 5.0.4
    • Using deface 1.3.2

I made a standalone Rails app to see if I could reproduce, and I could, but only in reverse. This was unexpected, but showcases that there is a problem, somewhere, with parsing of data attributes.

Here's the Rails app: https://github.com/meowsus/deface-haml5-bug

This time in the deface partial I am losing my data attributes. More information can be found on the original ticket (#172)

I hope this helps. Any ideas where this bug might be occurring would be very helpful.

Thanks in advance.

meowsus commented 4 years ago

There is an OSS God!