MtF-wiki/layouts/shortcodes/currency.html

9 lines
408 B
HTML
Raw Normal View History

2022-02-01 15:43:49 +08:00
{{- $from := .Get "from" -}}
2022-02-01 15:55:07 +08:00
{{- $to := default "CNY" (.Get "to") -}}
2022-02-01 15:43:49 +08:00
{{- $value := float (.Get "value") -}}
{{- with getJSON (printf "https://api.exchangerate-api.com/v4/latest/%s" $from) -}}
<abbr class="currency">
<span class="from">{{- lang.FormatCurrency 2 $from $value -}}</span>
2022-02-02 16:51:48 +08:00
<span class="to"> ≈ {{ lang.FormatCurrency 2 $to (mul $value (index .rates $to)) }}</span>
2022-02-01 15:43:49 +08:00
</abbr>
{{- end -}}