mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-20 21:31:32 +02:00
Merge commit '8b9803425e63e1b1801f8d5d676e96368d706722'
This commit is contained in:
@@ -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/
|
||||
|
Reference in New Issue
Block a user