Unable To Render HTML in AMP-HTML mustache template

566 Views Asked by At

I am using amp-list to call an API which has HTML as part of its response and using mustache template to render HTML like this {{{html-content}}}. The HTML in JSON response is something like this

"<h1 class=\"h1_class\">Some Header h1</h1>\n<p class=\"p_class\">Content Para 1\n</p><h2 class=\"h2_class\">Some Header h2</h2><p class=\"p_class\">Some Para 2\n</p><h2 class=\"h2_class\">Some Another Header h2</h2><p class=\"p_class\">Content Para 2\n</p><h2 class=\"h2_class\">Some Header h2</h2><p class=\"p_class\">Some More Content</p>"

The issue which I am facing here is none of the headers are getting rendered and none of the header classes/markup are visible in the DOM (headers are shown only as a string without any h1 or h2 markup). If I call the API with just the HTML content inside it, it is being shown in response tab in chrome developer tools with "h1", "h2" and "p" markup. I am not sure this is the limitation of the AMP or whether I am doing something wrong with the way I am passing HTML in JSON to mustache template.

I'll be very grateful for any help in this regard.

1

There are 1 best solutions below

0
On

Currently you cannot do that. We try to convince them https://github.com/ampproject/amphtml/issues/17352 but not any help :).