| 1 |
{{/* |
| 2 |
Parses the serialized data from the given URL and returns a map or an array. |
| 3 |
|
| 4 |
Supports CSV, JSON, TOML, YAML, and XML. |
| 5 |
|
| 6 |
@param {string} . The URL from which to retrieve the serialized data. |
| 7 |
@returns {any} |
| 8 |
|
| 9 |
@example {{ partial "get-remote-data.html" "https://example.org/foo.json" }} |
| 10 |
*/}} |
| 11 |
|
| 12 |
{{ $url := . }} |
| 13 |
{{ $data := dict }} |
| 14 |
{{ with try (resources.GetRemote $url) }} |
| 15 |
{{ with .Err }} |
| 16 |
{{ errorf "%s" . }} |
| 17 |
{{ else with .Value }} |
| 18 |
{{ $data = .Content | transform.Unmarshal }} |
| 19 |
{{ else }} |
| 20 |
{{ errorf "Unable to get remote resource %q" $url }} |
| 21 |
{{ end }} |
| 22 |
{{ end }} |
| 23 |
{{ return $data }} |