Amphtml: Are nested templates supported?

Created on 27 May 2020  路  4Comments  路  Source: ampproject/amphtml

AMP documentation says that the following example of nested templates is valid and operational
For example see: https://github.com/ampproject/amphtml/issues/21758

Here is a sample structure where the source for the nested <script> could be a JSON endpoint or <amp-state> and a child processor could be amp-date-display

<amp-list id="myList" src="https://foo.com/list.json">
  <template type="amp-mustache">
    <div>{{title}}</div>
       <script type="text/plain" template="amp-mustache">
         {{foo}}
       </script>
  </template>
</amp-list>

The structure does pass the validator but does not work.
In contrast, nested <templates> do work but are not valid.

This is causing some heartburn. Can we escalate a review here?

DiscussioQuestion runtime

All 4 comments

Looks like the nested template does generate a validator error. Documentation shows that nested templates are a problem here: https://github.com/ampproject/amphtml/blob/84bf6f3203fd7a0a27349a18a560761ae4490320/extensions/amp-mustache/amp-mustache.md#nested-templates

BTW, nested templates, using alternating <template> and <script>, do not work.
Alternatively, nested templates using <template> and <template> do work but are not valid.

@choumx Since nested templates using <template> and <template> work, would you update the validator to accept the working condition?

Unfortunately this is a validator technical limitation. Does referencing template by ID not work for your use case?

Was this page helpful?
0 / 5 - 0 ratings