Amphtml: Bind Expressions should support quote escaping

Created on 16 Mar 2020  Â·  2Comments  Â·  Source: ampproject/amphtml

What's the issue?

This issue was raised initially with amp-mustache #8395 and was resolved to some extent. But what about usage when someone is using apostrophe or other escape characters outside the template.
for example:

           <button on="tap:AMP.setState({
             message:'Hello I'm John Doe'
             })">
           Hello
           </button>
           <p [text]="message">HI</p>

Here, Console is throwing error:
%s %s amp-bind: Expression eval failed. Parse error on line 2: ... message:'Hello I'm John Doe' -----------------------^ Expecting 'EOF', ')', '-', '+', '*', '/', '%', '&&', '||', '<=', '<', '>=', '>', '!=', '==', '?', ':', '.', ',', '[', ']', '}', got 'NAME'​​​
And one can't use backslash escaping or html's &apos;. The solution provided in issue #8395 converts the content to text.
One solution can be allowing backslash escaping or HTML predefined characters entities should be allowed to be used in amp components.

amp-bind When Possible Bug Feature Request runtime

Most helpful comment

I like the idea of allowing backslashes to escape the quote.

All 2 comments

I like the idea of allowing backslashes to escape the quote.

Like JSON and double quotes

Was this page helpful?
0 / 5 - 0 ratings