I'm trying to display a floating point value as money in liquid script. It appears to only allow you to do this to numbers, however I can't convert a string to a number (despite following advice on SO as below:)
{% assign teststring = '202.2400' %}
{% assign testnumeric = 202.2400 %}
teststring: {{ teststring }} <br/>
testnumeric: {{ testnumeric }} <br/>
teststring as money: {{ teststring |money: "GBP" }} <br/>
testnumeric as money: {{ testnumeric |money: "GBP" }} <br/>
{% assign testStringAsNumeric = teststring | plus: 45 %}
test convert teststring to numeric: {{ testStringAsNumeric }} <br/>
test show above as money: {{ testStringAsNumeric |money: "GBP" }}
The output is:
teststring: 202.2400
testnumeric: 202.24
teststring as money: 202.2400
testnumeric as money: £202.24
test convert teststring to numeric: 202.24000
test show above as money: 202.24000
What I want is to show the string value (teststring) as money. So I need to convert to a number and then display as money.
I've also tried the times filter e.g.
{% assign testStringAsNumeric = teststring | times: 1 %}
test show above as money: {{ testStringAsNumeric |money: "GBP" }}
But this returns an error:
test show above as money: System.Linq.Enumerable+d__112`1[System.String]
Thanks for any help