Hi
I am struggling with the problem how to check if a variable exists (isset) within a range
.
Example: I want to show a name and possibly a link for some group of people.
My data is as follows: data/my_page.yml
(ie. ABC has a link, but XYZ has no link)
data:
- name: ABC
link: https://example.com
- name: XYZ
And my template is:
{{ range .Site.Data.my_page.data }}
{{ .name }}
IF LINK EXISTS FOR THE RANGE ITEM:
<a href="{{ .link }}>Link</a>
END
{{ end }}
Thanks!