extensions/amp-list/0.1/amp-list.js
/**
   * Request list data from `src` and return a promise that resolves when
   * the list has been populated with rendered list items. If the viewer is
   * capable of rendering the templates, then the fetching of the list and
   * transformation of the template is handled by the viewer.
   * @param {boolean=} opt_append
   * @param {boolean=} opt_refresh
   * @return {!Promise}
   * @private
   */
Request list data from `src` and return a promise that resolves when
the list has been populated with rendered list items. If the viewer is
capable of rendering the templates, then the fetching of the list and
transformation of the template is handled by the viewer.
@param {boolean=} opt_append
@param {boolean=} opt_refresh
@return {!Promise}
@private
Request list data from ` src ` and return a promise that resolves when the list has been populated with rendered list items . If the viewer is capable of rendering the templates then the fetching of the list and transformation of the template is handled by the viewer . @param { boolean = } opt_append @param { boolean = } opt_refresh @return { !Promise } @private
fetchList_(opt_append = false, opt_refresh = false) {
    if (!this.element.getAttribute('src')) {
      return Promise.resolve();
    }
    let fetch;
    if (this.ssrTemplateHelper_.isSupported()) {
      fetch = this.ssrTemplate_(opt_refresh);
    } else {
      const itemsExpr = this.element.getAttribute('items') || 'items';
      fetch = this.fetch_(opt_refresh).then(data => {
        let items = getValueForExpr(data, itemsExpr);
        if (this.element.hasAttribute('single-item')) {
          user().assert(typeof items !== 'undefined',
              'Response must contain an array or object at "%s". %s',
              itemsExpr, this.element);
          if (!isArray(items)) {
            items = [items];
          }
        } else if (this.loadMoreEnabled_) {
          const nextExpr = this.element.getAttribute('load-more-bookmark')
            || 'load-more-src';
          this.loadMoreSrc_ = 
            (getValueForExpr(data, nextExpr));
        }
        user().assert(isArray(items),
            'Response must contain an array at "%s". %s',
            itemsExpr, this.element);
        const maxLen = parseInt(this.element.getAttribute('max-items'), 10);
        if (maxLen < items.length) {
          items = items.slice(0, maxLen);
        }
        return this.scheduleRender_((items), !!opt_append);
      }, error => {
        throw user().createError('Error fetching amp-list', error);
      });
    }
    return fetch.catch(error => this.showFallback_(error));
  }
fetchList_ ( opt_append = false , opt_refresh = false ) { if ( ! this . element . getAttribute ( 'src' ) ) { return Promise . resolve ( ) ; } let fetch ; if ( this . ssrTemplateHelper_ . isSupported ( ) ) { fetch = this . ssrTemplate_ ( opt_refresh ) ; } else { const itemsExpr = this . element . getAttribute ( 'items' ) || 'items' ; fetch = this . fetch_ ( opt_refresh ) . then ( data => { let items = getValueForExpr ( data , itemsExpr ) ; if ( this . element . hasAttribute ( 'single-item' ) ) { user ( ) . assert ( typeof items !== 'undefined' , 'Response must contain an array or object at "%s". %s' , itemsExpr , this . element ) ; if ( ! isArray ( items ) ) { items = [ items ] ; } } else if ( this . loadMoreEnabled_ ) { const nextExpr = this . element . getAttribute ( 'load-more-bookmark' ) || 'load-more-src' ; this . loadMoreSrc_ = ( getValueForExpr ( data , nextExpr ) ) ; } user ( ) . assert ( isArray ( items ) , 'Response must contain an array at "%s". %s' , itemsExpr , this . element ) ; const maxLen = parseInt ( this . element . getAttribute ( 'max-items' ) , 10 ) ; if ( maxLen < items . length ) { items = items . slice ( 0 , maxLen ) ; } return this . scheduleRender_ ( ( items ) , ! ! opt_append ) ; } , error => { throw user ( ) . createError ( 'Error fetching amp-list' , error ) ; } ) ; } return fetch . catch ( error => this . showFallback_ ( error ) ) ; }
Request list data from `src` and return a promise that resolves when
 the list has been populated with rendered list items.
Request list data from ` src ` and return a promise that resolves when the list has been populated with rendered list items .
/** @type {string} */ /** @type {!Array} */