Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: toHTML decodes html entities in triple-curlies #2882

Closed
TehShrike opened this issue Feb 14, 2017 · 2 comments
Closed

Bug: toHTML decodes html entities in triple-curlies #2882

TehShrike opened this issue Feb 14, 2017 · 2 comments
Milestone

Comments

@TehShrike
Copy link
Contributor

TehShrike commented Feb 14, 2017

Description:

I'm using triple-curly braces to embed HTML into another template.

When that embedded HTML contains encoded HTML entities, they are incorrectly decoded in the toHTML() output string.

When output to the DOM, everything works fine. The issue only happens with toHTML().

Versions affected:

Introduced in 0.5.8, still in 0.8.10

Reproduction:

https://jsfiddle.net/qLz7j56t/2/

Code:

const r = window.r = new Ractive({
  el: '#main',
  template: `<p>{{{html}}}</p>`,
  data: {
    html: `<pre><code>This is &lt;strong&gt;legit&lt;/strong&gt;!</code></pre>`
  }
});


console.log(`Should be:
<p><pre><code>This is &lt;strong&gt;legit&lt;/strong&gt;!</code></pre></p>
`)
console.log(`Actually is:
${r.toHTML()}
`) // => <p><pre><code>This is <strong>legit</strong>!</code></pre></p>
@evs-chris
Copy link
Contributor

It looks like there were some tests added to make sure triples worked in attributes, but there wasn't coverage for non-attribute triples. This is now fixed in edge and v0.8-dev. It'll go out with 0.8.11 when it gets cut. Thanks for the report!

@TehShrike
Copy link
Contributor Author

Kickass turnaround time, thanks so much for the fix!

TehShrike added a commit to TehShrike/noddity-lazy-static-render that referenced this issue Feb 14, 2017
Use good old replace() instead of Ractive's {{{html}}} triple-curlies to embed the content.

This hack can be undone once Ractive 0.8.11 is released, as per ractivejs/ractive#2882
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants