I2I: amp-render - a simpler content fetching and rendering component
Summary
We propose amp-render - component that fetches and renders remote or inline JSON data with these features:
- render any shape of data (supported by mustache templates)
- customizable with JS to enable developers roll out their own features
- support layout="container"
Design document
https://docs.google.com/document/d/1V1rqeFmMT5bvM-z0iPR7wonbYtjwAQjMkBhmVDLrY8w/edit?ts=601c2449&pli=1#
Motivation
Currently, AMP developers have amp-list component to fetch and render remote data. While amp-list satisfies various use cases for rendering list data and offers features like infinite scroll and pagination, over time it has become complex to understand, maintain, and document. Plus, as developers have requested new functionality, we have provided new features leading to a slew of new attributes (e.g. single-item) and auxiliary components (e.g. amp-list-load-more). With amp-render we want to give developers the flexibility to render any shape of data, support layout="container" and add new features using JS leading to a simpler interface.
Additional context
Launch tracker
/cc @ampproject/wg-approvers
Hi @dmanek and any other amp-render contributors.
I was fearing I've been trying to do something that is inherently impossible, but having now seen the template attribute validation issue and newness of amp-render generally, I wonder if I may have found a bug? Or both. Or a.n. other.
I have documented my problem at StackOverflow, but in short the issue is that I am unable to render my dl-containing template in the correct position and size, with a variable number of dt/dd pairs to start with (pre-rendered into the page/template by my backend), and which may or may not return any additional data via the amp-render xhr, based on user permissions.
amp-render either renders in the correct position on the page by forces itself to zero height, leaving the content to spill underneath succeeding elements; or renders at a more correct size but absolutely positioned 0,0 in the viewport.
The above issue is being tracked in #35054.
Code complete. Closing.