AMP

amp-render

Description

Renders remote or inline data using a template.

 

Required Scripts

<script async custom-element="amp-render" src="https://cdn.ampproject.org/v0/amp-render-1.0.js"></script>

Ejemplos

Usage

The amp-render component fetches JSON data, then renders that data using a template. amp-render can use data from a CORS JSON endpoint, from an amp-state state variable, or from amp-script.

Since amp-render's data can come from amp-script, you can use your own JavaScript to filter data, cap its size, create list functionality, and otherwise customize the component's behavior and appearance. If you prefer to use HTML attributes, amp-list provides a richer feature set.

Your endpoint must implement the requirements specified in the CORS Requests in AMP spec.

You can specify a template in one of two ways:

  • a template attribute that references an ID of an existing templating element.
<template id="my-template" type="amp-mustache">
  Your personal offer: ${{price}}</template>
<amp-render template="my-template" src="https://example.com/data.json">
</amp-render>
  • a templating element nested directly inside the amp-render element.
<amp-render src="https://example.com/data.json">
  <