This commit is contained in:
Bjørn Erik Pedersen 2024-06-21 09:41:24 +02:00
commit af0cb57aaf
No known key found for this signature in database
475 changed files with 7408 additions and 4720 deletions

View file

@ -15,6 +15,18 @@ action:
toc: true
---
{{% deprecated-in 0.123.0 %}}
Instead, use [`transform.Unmarshal`] with a [global], [page], or [remote] resource.
See the [remote data example].
[`transform.Unmarshal`]: /functions/transform/unmarshal/
[global]: /getting-started/glossary/#global-resource
[page]: /getting-started/glossary/#page-resource
[remote data example]: /functions/resources/getremote/#remote-data
[remote]: /getting-started/glossary/#remote-resource
{{% /deprecated-in %}}
Given the following directory structure:
```text
@ -31,7 +43,7 @@ Access the data with either of the following:
```
{{% note %}}
When working with local data, the filepath is relative to the working directory.
When working with local data, the file path is relative to the working directory.
You must not place CSV files in the project's data directory.
{{% /note %}}
@ -81,7 +93,7 @@ my-project/
```
```go-html-template
{{ $data := "" }}
{{ $data := dict }}
{{ $p := "data/pets.csv" }}
{{ with resources.Get $p }}
{{ $opts := dict "delimiter" "," }}
@ -105,7 +117,7 @@ my-project/
```
```go-html-template
{{ $data := "" }}
{{ $data := dict }}
{{ $p := "pets.csv" }}
{{ with .Resources.Get $p }}
{{ $opts := dict "delimiter" "," }}
@ -120,7 +132,7 @@ my-project/
Consider using the [`resources.GetRemote`] function with [`transform.Unmarshal`] when accessing a remote resource to improve error handling and cache control.
```go-html-template
{{ $data := "" }}
{{ $data := dict }}
{{ $u := "https://example.org/pets.csv" }}
{{ with resources.GetRemote $u }}
{{ with .Err }}
@ -134,7 +146,7 @@ Consider using the [`resources.GetRemote`] function with [`transform.Unmarshal`]
{{ end }}
```
[`Resources.Get`]: methods/page/Resources
[`resources.GetRemote`]: /functions/resources/getremote
[`resources.Get`]: /functions/resources/get
[`transform.Unmarshal`]: /functions/transform/unmarshal
[`Resources.Get`]: /methods/page/resources/
[`resources.GetRemote`]: /functions/resources/getremote/
[`resources.Get`]: /functions/resources/get/
[`transform.Unmarshal`]: /functions/transform/unmarshal/