reflect.IsResource
报告给定值是否为资源(Resource)对象。
(0.154.0 新增)
项目结构如下:
project/
├── assets/
│ ├── a.json
│ ├── b.avif
│ └── c.jpg
└── content/
└── example/
├── index.md
├── d.json
├── e.avif
└── f.jpg下例给出 reflect.IsResource 函数返回的值:
{{ with resources.Get "a.json" }}
{{ reflect.IsResource . }} → true
{{ end }}
{{ with resources.Get "b.avif" }}
{{ reflect.IsResource . }} → true
{{ end }}
{{ with resources.Get "c.jpg" }}
{{ reflect.IsResource . }} → true
{{ end }}{{ with .Resources.Get "d.json" }}
{{ reflect.IsResource . }} → true
{{ end }}
{{ with .Resources.Get "e.avif" }}
{{ reflect.IsResource . }} → true
{{ end }}
{{ with .Resources.Get "f.jpg" }}
{{ reflect.IsResource . }} → true
{{ end }}{{ with site.GetPage "/example" }}
{{ reflect.IsResource . }} → true
{{ end }}