Intent to Implement: amp-remote-renderer
amp-remote-renderer element will be similar to amp-list. It will fetch data from a remote endpoint and will render its content via template. However, it will have none of the list semantics.
<amp-remote-renderer
src="https://data.com/data.json?ref=CANONICAL_URL"
credentials=include
width=300 height=200 layout=responsive>
<template type="amp-mustache">
<div>
<amp-img src="{{imageUrl}}" width=50 height=50></amp-img>
{{title}}
</div>
</template>
</amp-remote-renderer>
Usage
The amp-remote-renderer defines data source using the following attributes:
srcdefines a CORS URL. The URL's protocol must be HTTPS. The URL can use all URL variables available.credentialsdefines a credentials option as specified by the Fetch API. To send credentials, pass the value of "include".
The response must be a JSON value.
The template can be specified using either of the following two ways:
templateattribute that references an ID of an existing template element.templateelement nested directly inside of thisamp-remote-rendererelement.
For more details on templates see AMP HTML Templates.
Behavior
The loading is triggered using normal AMP rules depending on how far the element is from the current viewport.
If amp-remote-renderer needs more space after loading it requests the AMP runtime to update its height using the normal AMP flow. This is done normal AMP rules including fallback to overflow element if specified.
Assigning to @cramforce to review the spec and suggest a different name if this one doesn't work.
/cc @jcap-pro
Totally never saw this :)
Why not amp-render?
Otherwise LGTM
Trying to create an Amp-carousel using Amp-mustache.. Is that even possible
<template type="amp-mustache" id="amp-template-id">
<li>
<amp-carousel width="400"
height="244"
layout="fixed"
type="slides"
autoplay
delay="4000">
<amp-img width="400"
height="244"
layout="fixed"
src="{{src}}"></amp-img>
</amp-carousel>
</li>
</template>
<div overflow
role=button
aria-label="Show more"
class="list-overflow">
Show more
</div>
</amp-list>
/cc @ericlindley-g
@escoffierdesign at this time we err on the side of not having client-side rendering logic outside of basic auxiliary content. The reason for this is that server-side rendering would be more performant than client-side in most of cases.
What is your use case for combining amp-mustache and amp-carousel?
I was wanting to call pictures using a JSON file and put them into the carousel. and hence create a template structure that would allow different pictures to be called for different pages dependent on the JSON file associated with it. Different restaurants with different pictures may change come the changing of the seasons or even on a weekly basis/daily basis. With the front end of AMP being so sleek and fast I was trying to get functionality into the back end and for me the Carousel starts at the top of the page and engages the user.
The JSON information could later be an important factor in google Search results
The Carousel, for me, is one of the strengths that AMP has over, responsive sights and is fundamental to presentations, especially on a phone. This would add more Power and flexibility to what is already existing.
@rudygalfi see above:
@dvoytenko Ok Dvoytenko. Is there a work around or another element that could be utilized for this purpose or is it a dead end with regards to the functionality of AMP Carousle within the AMP Moustache element at the moment?
It sounds like for your use case there would still be a 1:1 mapping between a page (a specific URL) and the images that you would want to display in the carousel (as specified by what the JSON response is). I think for this kind of scenario, it's much better to statically encode that information into the AMP page so that rendering doesn't get blocked on another request.
@rudygalfi @escoffierdesign @ericlindley-g This might be a bigger thread and a bigger use case here than I originally thought. To start with, can we confirm whether this and #4405 duplicate issues in terms of use cases/needs?
Well, this ITI seems more general, but I agree that the idea of a dynamically generated amp-carousel is covered by #4405.
@rudygalfi @escoffierdesign @ericlindley-g @dvoytenko It seems like this is covered in #4405 which then points back to this page #1446. Which is : Intent to Implement: amp-remote-renderer. So i am now looking for more information on "amp remote render" and weather it is a work in progress or still in the developmental stage. Appreciate the advice and the response people and really diggin the AMP project...
Ok. Let's disassociate these two and proceed on the discussion about the carousel with the remote remote data on #4405.
Lat issue referenced here was closed. Anything else left to be done here? Thanks.
@dvoytenko , is this feature something you're still considering? (bearing in mind that https://github.com/ampproject/amphtml/issues/7463 is in the works—I'm not sure how much the use cases for these overlap)
@ericlindley-g Yes, still considering. But it's in a queue behind bind protocol and amp-fresh which can change this vision.
+1 for this. Our use case is to render the share count from Facebook using the graph API. It returns an array and not an object.
Dedup with #23587