Reputation: 1412
How can I get the index of each item that is rendered with Mustache inside an Amp-list? Here's an example of my html :
<amp-list id=""
layout="fixed-height"
height="130"
binding="no"
items="."
single-item="."
src="https://api.myjson.com/bins/6jjqc">
<template type="amp-mustache">
<amp-carousel carousel-preview"
width="auto"
height="130"
layout="fixed-height"
type="carousel">
<a on="tap:carousel-with-carousel-preview.goToSlide(index={{@index}})" class="dayweek">{{day}}</a>
</amp-carousel>
</template>
</amp-list>
I have used {{@index}} but since this HTML is rendered inside C#, C# thinks @index is a variable and sends an error
Upvotes: 0
Views: 242
Reputation: 39274
"rendered inside C#" - I assume you mean it is rendered by a Razor View?
In that case you will need to escape your @
by doubling it, to have Razor output a literal @
without interpreting it as a variable.
See the docs:
When an @ symbol is followed by a Razor reserved keyword, it transitions into Razor-specific markup. Otherwise, it transitions into plain C#.
To escape an @ symbol in Razor markup, use a second @ symbol:
<p>@@Username</p>
Upvotes: 1