Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
An example of how to get around displaying erroneous html in AMP Templates.
CSS :
<style>
.noDisplay : { display: none; }
</style>
JSON :
{
"items": [{
{
"priceType:"",
"price": "1.99",
},
{
"priceType":"Card",
"price": "2.99",
},
{
"priceType":"BitCoin",
"price": "5.99",
}
}]
}
AMP List Template :
<template type="amp-mustache">
<table>
<tr class=”noDisplay{{priceType}}”>
<td>{{priceType}}:</td>
<td>$ {{price}}</td>
</tr>
</table>
</template>
Resulting HTML:
<table>
<tr class=”noDisplay”>
<td></td>
<td>1.99</td>
</tr>
<tr class=”noDisplayCard”>
<td>Card</td>
<td>2.99</td>
</tr>
<tr class=”noDisplayBitCoin”>
<td>BitCoin</td>
<td>5.99</td>
</tr>
</table>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.