Debian Codegraph @

docs/content/en/functions/reflect/IsResource.md

raw
1 ---
2 title: reflect.IsResource
3 description: Reports whether the given value is a Resource object.
4 categories: []
5 keywords: []
6 params:
7 functions_and_methods:
8 aliases: []
9 returnType: bool
10 signatures: [reflect.IsResource INPUT]
11 ---
12
13 {{< new-in 0.154.0 />}}
14
15 With this project structure:
16
17 ```tree
18 project/
19 ├── assets/
20 │ ├── a.json
21 │ ├── b.avif
22 │ └── c.jpg
23 └── content/
24 └── example/
25 ├── index.md
26 ├── d.json
27 ├── e.avif
28 └── f.jpg
29 ```
30
31 These are the values returned by the `reflect.IsResource` function:
32
33 ```go-html-template {file="layouts/page.html"}
34 {{ with resources.Get "a.json" }}
35 {{ reflect.IsResource . }} → true
36 {{ end }}
37
38 {{ with resources.Get "b.avif" }}
39 {{ reflect.IsResource . }} → true
40 {{ end }}
41
42 {{ with resources.Get "c.jpg" }}
43 {{ reflect.IsResource . }} → true
44 {{ end }}
45 ```
46
47 ```go-html-template {file="layouts/page.html"}
48 {{ with .Resources.Get "d.json" }}
49 {{ reflect.IsResource . }} → true
50 {{ end }}
51
52 {{ with .Resources.Get "e.avif" }}
53 {{ reflect.IsResource . }} → true
54 {{ end }}
55
56 {{ with .Resources.Get "f.jpg" }}
57 {{ reflect.IsResource . }} → true
58 {{ end }}
59 ```
60
61 ```go-html-template {file="layouts/page.html"}
62 {{ with site.GetPage "/example" }}
63 {{ reflect.IsResource . }} → true
64 {{ end }}
65 ```