amp-form not populating template element
See original GitHub issueI have a simple amp-form which passed validation but, when submitted, does not populate the template
values in submit-success
or submit-error
.
The server is currently returning a simple (canned) JSON payload of {"interesting": false, "name": "John Doe"}
with a status code of 200
. I have also responded with a 403
code and the same JSON payload and the error processing is successfully triggered but no token population takes place.
The payload headers are;
access-control-allow-credentials:true
access-control-allow-headers:Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token
access-control-allow-methods:POST, GET, OPTIONS
access-control-allow-origin:https://unlimitedbroadband.org.uk
access-control-expose-headers:AMP-Access-Control-Allow-Source-Origin
amp-access-control-allow-source-origin:https://unlimitedbroadband.org.uk
Content-Length:75
Content-Type:application/json
Date:Thu, 12 Jan 2017 12:42:09 GMT
Server:Apache/2.4.25 (Ubuntu)
I appreciate I don’t need all of these but I was attempting to eliminate any obvious issues.
Any feedback appreciated.
Issue Analytics
- State:
- Created 7 years ago
- Comments:14 (7 by maintainers)
@mkhatib, you have spotted a massive oversight on my part for which I apologise profusely for wasting your time. The page is being drawn via a Jinja2 template engine extension to Flask which recognises
{
as a control character, clashing with its usage in the mustache.I have now escaped it and it is working as expected.
Once again, sorry for wasting your time and thanks for your patience, it’s much appreciated.
For anyone that stumbles upon this and is working with Django Templates and implementing form submission success using amp-form you will need to wrap your {{message}} value with the following template tag:
This should allow the amp-form to render the JsonResponse object values from your django view (provided you had a successful post.)
Reference to Django Docs https://docs.djangoproject.com/en/3.1/ref/templates/builtins/#verbatim
Was freaking out for a couple hours trying to figure this out.