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
amp-mustache: Auto escaping of quote chars #8395
Comments
Is there a case this doesn't work for? I just tried: <p [text]="'"' + sentence + '"'"></p>
<button on="tap:AMP.setState({sentence: 'the "button" was pressed'})"></button> Where pressing the button will change the p tag's text to: EDIT: Just realized this issue is for escaping the single quote / apostrophe. EDIT 2: <p [text]="'"' + sentence + '"'"></p>
<button on="tap:AMP.setState({sentence: "Don't tread on me!"})"></button> Pressing the button changes the p tag's text to |
Hi - any update on this issue? Quote escaping is particularly important in e-commerce use cases where single / double quotes appear quite frequently. |
Does @kmh287's workaround (above) work for those use cases? |
For single quotes, would |
Not sure I fully understand. In your example above, it looks like the HTML is: <button class="btn" on="tap:AMP.setState({sentence: "'Boot's Attributes is 3" and above "})"> Looks like the value of the sentence: "'Boot's Attributes is 3" and above " What you probably want is this: sentence: 'Boot's Attributes is 3" and above' |
Hey William, thank you for the quick feedback, I have tried
and it is still not working, anyway, I have found a solution for this. Which is :
|
Changing this FR to track auto-escaping in |
Dev-ex would be improved if we can avoid the need for developers to change backend data (e.g. replace E.g. in the example below, rendering with the <template type="amp-mustache">
<button on="tap:AMP.setState(foo: 'Templated {{bar}} needs quote escaping')">
</button>
</template> We can support a {
bar: "This single-quote (') causes a runtime error",
quotable: function() {
return (text, render) => render(text.replace("'", "′"));
}
} <template type="amp-mustache">
<button on="tap:AMP.setState(foo: '{{#quotable}}{{bar}}{{/quotable}}')">
</button>
</template> |
It's not quite the same issue, but this also happens when using amp-mustache templates in amp-bind. We could replace the quote in our api but we don't want to do this to avoid causing edge cases. Ideally we would just output the data from mustache and escape the strings, but that doesn't appear to be an option at present |
New feature: If you use See https://github.com/ampproject/amphtml/blob/master/extensions/amp-mustache/amp-mustache.md#usage for details. This is probably preferable to the "auto-escaping" proposal above. |
Closing as obsolete. |
No description provided.
The text was updated successfully, but these errors were encountered: