es6-string-html icon indicating copy to clipboard operation
es6-string-html copied to clipboard

Backslash escape not detected

Open shenghan97 opened this issue 2 years ago • 3 comments

I'm trying to use backtick inside of a template string, but it seems like the plug in is not correctly detecting the escaped backtick. Here's a sample of the code.

template: html`
    <div
      class="classname"
      :style="background-image: url(\`${cardImage ??
        imgPlaceholder}');background-size: cover; cursor: pointer;\`
    >
      <div class="classname">
        <span class="classname" style=""
          >{{ title }}</span
        >
      </div>
    </div>
  `,

Could this be a bug?

shenghan97 avatar Mar 03 '23 17:03 shenghan97

image I also have this issue

Dunks1980 avatar Apr 22 '23 18:04 Dunks1980

Could something like this be done?

/*HTML*/`
code .....  \`  `
`/*HTML*/;

Dunks1980 avatar Apr 29 '23 13:04 Dunks1980

\${ is also affected

example

const html = /* html */ `
<ul>
  <li data-value="${ JSON.stringify(1 + 1) }"></li> <!-- 🙂 -->
  <li data-value="\${ JSON.stringify(1 + 1) }"></li> <!-- 🙁 -->
  <li data-value="$\{ JSON.stringify(1 + 1) }"></li> <!-- 🙂 -->
  <li data-value="` + JSON.stringify(1 + 1) + `"></li> <!-- 🫤 -->
</ul>
`

actual render

Screenshot_20240229_131642

expected render

Screenshot_20240229_131642-exp

yukulele avatar Feb 29 '24 12:02 yukulele