Skip to content

<template> without type not allowed #40280

@eps1lon

Description

@eps1lon

Description

amphtml-validator will currently fail when a <template> without a type is rendered with two errors:

  1. The mandatory attribute 'type' is missing in tag 'template'.
  2. The tag 'template' requires including the 'amp-mustache' extension JavaScript.

It's unclear from the linked documentation why this is a validation error.

React uses <template> to inform the browser to throttle rendering until that element is streamed in (see #40279).

Reproduction Steps

Validate

<!DOCTYPE html>
<html lang="en-US" amp i-amphtml-layout i-amphtml-no-boilerplate transformed="self;v=1">
    <head>
        <meta charset="utf-8" data-next-head>
        <meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1">
        <style amp-runtime i-amphtml-version="012504091801000"></style>
        <script async src="https://cdn.ampproject.org/v0.mjs" type="module" crossorigin="anonymous"></script>
        <script async nomodule src="https://cdn.ampproject.org/v0.js" crossorigin="anonymous"></script>
        <link rel="expect" href="#«R»" blocking="render">
        <link rel="canonical" href="/amp/amp-first">
        <style amp-custom></style>
    </head>
    <body>
        <p id="another">another page</p>
        <template id="«R»"></template>
    </body>
</html>

Relevant Logs

The mandatory attribute 'type' is missing in tag 'template'.                   
 https://amp.dev/documentation/components/amp-mustache
The tag 'template' requires including the 'amp-mustache' extension JavaScript.  https://amp.dev/documentation/components/amp-mustache

Browser(s) Affected

No response

OS(s) Affected

No response

Device(s) Affected

No response

AMP Version Affected

No response

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions