How can I make a range display having this code?

Hello, I would like to do something similar to the following images,

but I don’t know why the If where it says “and template == ‘collection’” is in price.liquid line 85
it doesn’t detect it
I don’t know if there would be another way to do it better so that in the Featured Collection section the range that I have for the maximum and minimum price appears, when you enter the product the two ranges appear and when you select the material I put the price that it is worth.

{{ ‘products.product.price.regular_price’ | t }}> > > {% if product.price_varies and template == ‘collection’ %}>

From {{ product.price_min | money }} to {{ product.price_max | money }}

{% elsif money_price == money_price_min %}> {{ money_price }}> {% elsif money_price == money_price_max %}> {{ money_price }}> {% elsif money_price != money_price_min and money_price != money_price_max %}> {{ money_price }}> {% else %}> {{- ‘products.product.volume_pricing.price_range’ | t: minimum: money_price_min, maximum: money_price_max -}}> {% endif %}> >

Thank you so much