MtF-wiki/layouts/shortcodes/currency.html

9 lines
405 B
HTML

{{- $from := .Get "from" -}}
{{- $to := default "CNY" (.Get "to") -}}
{{- $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">&asymp; {{ lang.FormatCurrency 2 $to (mul $value (index .rates $to)) }}</span>
</abbr>
{{- end -}}