mirror of
https://github.com/gohugoio/hugoDocs.git
synced 2025-09-13 09:30:24 -04:00
Fix default data type
This commit is contained in:
parent
61319af7ad
commit
b276bb17f2
@ -93,7 +93,7 @@ my-project/
|
||||
```
|
||||
|
||||
```go-html-template
|
||||
{{ $data := "" }}
|
||||
{{ $data := dict }}
|
||||
{{ $p := "data/pets.csv" }}
|
||||
{{ with resources.Get $p }}
|
||||
{{ $opts := dict "delimiter" "," }}
|
||||
@ -117,7 +117,7 @@ my-project/
|
||||
```
|
||||
|
||||
```go-html-template
|
||||
{{ $data := "" }}
|
||||
{{ $data := dict }}
|
||||
{{ $p := "pets.csv" }}
|
||||
{{ with .Resources.Get $p }}
|
||||
{{ $opts := dict "delimiter" "," }}
|
||||
@ -132,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 }}
|
||||
|
@ -98,7 +98,7 @@ my-project/
|
||||
```
|
||||
|
||||
```go-html-template
|
||||
{{ $data := "" }}
|
||||
{{ $data := dict }}
|
||||
{{ $p := "data/books.json" }}
|
||||
{{ with resources.Get $p }}
|
||||
{{ $data = .Content | transform.Unmarshal }}
|
||||
@ -121,7 +121,7 @@ my-project/
|
||||
```
|
||||
|
||||
```go-html-template
|
||||
{{ $data := "" }}
|
||||
{{ $data := dict }}
|
||||
{{ $p := "books.json" }}
|
||||
{{ with .Resources.Get $p }}
|
||||
{{ $data = .Content | transform.Unmarshal }}
|
||||
@ -135,7 +135,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/books.json" }}
|
||||
{{ with resources.GetRemote $u }}
|
||||
{{ with .Err }}
|
||||
|
@ -11,7 +11,7 @@ action:
|
||||
---
|
||||
|
||||
```go-html-template
|
||||
{{ $data := "" }}
|
||||
{{ $data := dict }}
|
||||
{{ $p := "data/books.json" }}
|
||||
{{ with resources.Get $p }}
|
||||
{{ $opts := dict "delimiter" "," }}
|
||||
|
@ -73,7 +73,7 @@ When retrieving remote data, use the [`transform.Unmarshal`] function to [unmars
|
||||
[unmarshal]: /getting-started/glossary/#unmarshal
|
||||
|
||||
```go-html-template
|
||||
{{ $data := "" }}
|
||||
{{ $data := dict }}
|
||||
{{ $url := "https://example.org/books.json" }}
|
||||
{{ with resources.GetRemote $url }}
|
||||
{{ with .Err }}
|
||||
|
@ -46,10 +46,10 @@ assets/
|
||||
```
|
||||
|
||||
```go-html-template
|
||||
{{ $data := "" }}
|
||||
{{ $data := dict }}
|
||||
{{ $path := "data/books.json" }}
|
||||
{{ with resources.Get $path }}
|
||||
{{ with unmarshal .Content }}
|
||||
{{ with .Content | transform.Unmarshal }}
|
||||
{{ $data = . }}
|
||||
{{ end }}
|
||||
{{ else }}
|
||||
@ -75,10 +75,10 @@ content/
|
||||
```
|
||||
|
||||
```go-html-template
|
||||
{{ $data := "" }}
|
||||
{{ $data := dict }}
|
||||
{{ $path := "books.json" }}
|
||||
{{ with .Resources.Get $path }}
|
||||
{{ with unmarshal .Content }}
|
||||
{{ with .Content | transform.Unmarshal }}
|
||||
{{ $data = . }}
|
||||
{{ end }}
|
||||
{{ else }}
|
||||
@ -95,7 +95,7 @@ content/
|
||||
A remote resource is a file on a remote server, accessible via HTTP or HTTPS.
|
||||
|
||||
```go-html-template
|
||||
{{ $data := "" }}
|
||||
{{ $data := dict }}
|
||||
{{ $url := "https://example.org/books.json" }}
|
||||
{{ with resources.GetRemote $url }}
|
||||
{{ with .Err }}
|
||||
@ -166,7 +166,7 @@ When unmarshaling an XML file, do not include the root node when accessing data.
|
||||
Get the remote data:
|
||||
|
||||
```go-html-template
|
||||
{{ $data := "" }}
|
||||
{{ $data := dict }}
|
||||
{{ $url := "https://example.org/books/index.xml" }}
|
||||
{{ with resources.GetRemote $url }}
|
||||
{{ with .Err }}
|
||||
|
Loading…
x
Reference in New Issue
Block a user