amphtml icon indicating copy to clipboard operation
amphtml copied to clipboard

Intent to Implement: amp-remote-renderer

Open dvoytenko opened this issue 10 years ago • 18 comments

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:

  • src defines a CORS URL. The URL's protocol must be HTTPS. The URL can use all URL variables available.
  • credentials defines 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:

  • template attribute that references an ID of an existing template element.
  • template element nested directly inside of this amp-remote-renderer element.

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.

dvoytenko avatar Jan 15 '16 18:01 dvoytenko

Assigning to @cramforce to review the spec and suggest a different name if this one doesn't work.

/cc @jcap-pro

dvoytenko avatar Jan 15 '16 18:01 dvoytenko

Totally never saw this :)

Why not amp-render?

cramforce avatar Feb 05 '16 17:02 cramforce

Otherwise LGTM

cramforce avatar Feb 05 '16 17:02 cramforce

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> 

escoffierdesign avatar Nov 09 '16 12:11 escoffierdesign

/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.

dvoytenko avatar Nov 09 '16 21:11 dvoytenko

What is your use case for combining amp-mustache and amp-carousel?

rudygalfi avatar Nov 09 '16 22:11 rudygalfi

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.

escoffierdesign avatar Nov 10 '16 08:11 escoffierdesign

@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?

escoffierdesign avatar Nov 10 '16 12:11 escoffierdesign

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 avatar Nov 10 '16 17:11 rudygalfi

@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?

dvoytenko avatar Nov 10 '16 17:11 dvoytenko

Well, this ITI seems more general, but I agree that the idea of a dynamically generated amp-carousel is covered by #4405.

rudygalfi avatar Nov 10 '16 17:11 rudygalfi

@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...

escoffierdesign avatar Nov 11 '16 09:11 escoffierdesign

Ok. Let's disassociate these two and proceed on the discussion about the carousel with the remote remote data on #4405.

dvoytenko avatar Nov 11 '16 16:11 dvoytenko

Lat issue referenced here was closed. Anything else left to be done here? Thanks.

adelinamart avatar Feb 07 '17 20:02 adelinamart

@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 avatar Feb 17 '17 02:02 ericlindley-g

@ericlindley-g Yes, still considering. But it's in a queue behind bind protocol and amp-fresh which can change this vision.

dvoytenko avatar Feb 17 '17 18:02 dvoytenko

+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.

bjalford avatar May 18 '17 02:05 bjalford

Dedup with #23587

caroqliu avatar Jun 24 '20 13:06 caroqliu