encoding.Base64Decode
语法
encoding.Base64Decode INPUT
返回值
string
别名
base64Decode
{{ "SHVnbw==" | base64Decode }} → Hugo
使用 base64Decode
函数解码来自 API 的响应。例如,此对 GitHub API 的调用的结果包含存储库的 README 文件的 base64 编码表示形式
https://api.github.com/repos/gohugoio/hugo/readme
要检索和渲染内容
{{ $url := "https://api.github.com/repos/gohugoio/hugo/readme" }}
{{ with try (resources.GetRemote $url) }}
{{ with .Err }}
{{ errorf "%s" . }}
{{ else with .Value}}
{{ with . | transform.Unmarshal }}
{{ .content | base64Decode | markdownify }}
{{ end }}
{{ else }}
{{ errorf "Unable to get remote resource %q" $url }}
{{ end }}
{{ end }}