MtF-wiki/layouts/shortcodes/currency.html

9 lines
413 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>
<span class="to">(约折合 {{ lang.FormatCurrency 2 $to (mul $value (index .rates $to)) }}</span>
</abbr>
{{- end -}}