Skip to content

Would you consider an API for custom html.replace functionality?Β #41

@m4ttsch

Description

@m4ttsch

Hey there! πŸ‘‹

I needed to add some functionality today that replaces random attributes with deterministic ones. Specifically, I am working with v-tooltip, which generates random ids that end up in the component's HTML.

I essentially needed to add a line after this one that was something to the effect of html = standardizeRandomIDs(html), but your library currently doesn't expose a way to add that functionality.

I had to copy your library to a local file and add the custom replace myself. 😒

Would you consider opening up your print method to optionally take a callback that defines custom replace logic? Something like:

module.exports = {
  // test (received) { ... },
  print (received, cb) {
    let html = (isVueWrapper(received) ? received.html() : received) || ''
    html = removeServerRenderedText(html)
    html = removeDataTestAttributes(html)
    if(cb) html = cb(html)
    return beautify(html, { indent_size: 2 })
  }
}

That way, I could have a least imported it and created a wrapper around it instead of copying and pasting all the code over to make the edits.

What do you think?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions