<amp-list> only supports external json. How to use local json?

I am experimenting with a component to use local json, as in the following example:

<div>
  <amp-list layout=fill>
    <script type="application/json">
      {"items":[{"name":"John"},{"name":"Paul"},{"name":"George"},{"name":"Ringo"}]}
    </script>
    <template type="amp-mustache">
      <div>
        Beatles musician: {{name}}
      </div>
    </template>
  </amp-list>
</div>

I get the following error:

The required attribute 'src' is missing from the 'amp-list' tag. More details ...

Only external json seems to be supported.

How can I use local (built-in) json in AMP?

+4
source share
1 answer

If json is available at the time the document is created, it is preferable that you simply enable the server-side template. One of the principles of AMP is to work at an appropriate level, which in your case is located on the server, and not in the user's browser.

, AMP , , src URL https.

+1

Source: https://habr.com/ru/post/1661484/


All Articles