How to use toLowerCase method in amp- mustache template variable

1.2k views Asked by At

I am binding the amp-list with a JSON. The problem is I am providing the array element for amp-img and the src for amp-img must be in lower case as the asset on my server is in lowercase.

<amp-list layout="fixed-height" height= "10" [height]="getData().length * 50" 
   [src]="getData()" id="datalist" items=".">
    <template type="amp-mustache">
        <amp-img alt="image"
            width="100"
            height="100"
            src="static/{{name}}.png">
            // I want to use {{name.toLowerCase()}} here which is causing the problem
           // Current src= "static/XYZ.png"
          // Expected src= "static/xyz.png"
        </amp-img>
    </template>
</amp-list>
1

There are 1 answers

0
Ashish On

After trying multiple approaches, I achieved what I wanted to like this: [src]="'static/{{ name }}.png'.toLowerCase()"

Code Sample:

<amp-list layout="fixed-height" height= "10" [height]="getData().length * 50" 
[src]="getData()" id="datalist" items=".">
    <template type="amp-mustache">
        <amp-img alt="image"
            width="100"
            height="100"
            [src]="'static/{{ name }}.png'.toLowerCase()">
        </amp-img>
    </template>
</amp-list>