I am trying to replicate this example without success. I want to add a list using a template mustache, for example:
<ul>
<amp-list width=auto
height=100
layout=fixed-height
src="/assets/popular.json">
<template type="amp-mustache"
id="amp-template-id">
<li>
<a href={{url}}>{{title}}</a>
</li>
</template>
</amp-list>
</ul>
My /assets/popular.jsonfile:
{
"items": [
{
"title": "amp-carousel",
"url": "https://ampbyexample.com/components/amp-carousel"
},
{
"title": "amp-img",
"url": "https://ampbyexample.com/components/amp-img"
},
{
"title": "amp-ad",
"url": "https://ampbyexample.com/components/amp-ad"
},
{
"title": "amp-accordion",
"url": "https://ampbyexample.com/components/amp-accordion"
}
]
}
But I can not get it to work, the values in are jsonnot replaced in the template, I get this error:
Missing URL for attribute 'href' in tag 'a'
I do not know why the value {{url}}will not be correctly replaced by the content json.
I added the necessary to my head scripts.
source
share