Say i have front matter for a “product” like this
+++
name = "Awesome android phone"
price = "13500"
priceunit = "INR"
+++
I want the price info to be displayed something like this
13,500 ₹
Note the Currency display
and comma separation
How do i do this? Im using the latest version 0.17
Seems to be an enhancement that could come up in the future… Intresting stuff here…
https://github.com/nicksnyder/go-i18n/issues/45
Jura
3
In the current schedule, the 0.19 release will contain a feature to format numbers. See tpl: Add numFormat func.
For the currency feature you’re asking I’m not aware of a Github issue.
I think sub
should do the string-to-float casting while int
does not.
{{ int (sub $amazon_price $newegg_price) }}
I have just discovered a JS feature which enables me to render currencies in appropriate format according to the currency code.
const price = 12
const formattedPrice = price.toLocaleString("en-US", { style: "currency", currency: "USD" })
console.log(formattedPrice)
this will give the output
$1.00