PolymerElements/iron-demo-helpers

Display attributes with double quotes inside using single quotes

Opened this issue · 4 comments

Object literals in the code snippets look better if they don't contain " escaping. E.g. using

        // Attributes with embedded JSON look better with apostrophes.
        snippet = snippet.replace(/="[^"]*"[^"]*"/g, function(s) {
          // If there are apostrophes, be safe and don't fiddle with it.
          if (s.indexOf("'") !== -1 || s.indexOf(''') !== -1)
            return s;

          return s.replace(/"/g, "'").replace(/"/g, '"');
        });

This should not have more false-positives than the empty attribute removal already in place.

eugef commented

Any plans to implement this fix?

There's no PR for this at the moment. I would tend to prefer less magic in that regex, but if it came with a bunch of tests, I would review it :)

I think tommi's snippet works fine, I tested it on jsbin: https://jsbin.com/berezuc/edit?html,js,output. Nice looking object literals would be really helpful for me.