In my template, I would like to include some default meta
tags (90% of the time). However, when a specific property is set, I would like to show a different set of text.
I know I can set an anonymous struct
and set a property with either "default"
or "some-x"
. However, this means, I need to add an anonymous struct to 90% of my handlers that just currently pass nil
.
Is there way to do something like
{{if eq . nil}}
// default meta tag
{{else if eq .MetaValue "some-x"}}
//other
{{end}}
If I try something like my above code, it compiles but doesn't do what I want. Appreciate any suggestions on how to handle it properly without adding a lot of boiler plate.
Thanks!
{{if not .}}
output when . is nil or otherwise empty including
false, 0, and any array, slice, map, or string of length zero
{{else if eq .MetaValue "some-x"}}
// some-x case
{{else}}
// other case
{{end}}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With