You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A section in the template had to look slightly different depending on the type of metadata being passed in, which I solved by using a custom hasField method:
{{if hasField $.Metadata "Foo"}}
We have Foo.
{{else}}
We have no Foo.
{{end}}
Hi @mbezhanov, as sprig seams to be not maintained actually, we decide to create a fork to go forward.
You can go forward by creating and reference this initial issue on https://github.com/go-sprout/sprout and you can create a PR for sure in the registry reflect.
Recently worked on a project that used generics in a similar fashion:
Then, similar objects were being passed to a template for rendering:
A section in the template had to look slightly different depending on the type of metadata being passed in, which I solved by using a custom
hasField
method:The
hasField
method comes from this StackOverflow thread: Field detection in Go HTML template and looks like this:Full code example
Would you approve a PR that adds a
hasField
method to Sprig, or is that something you prefer to keep separate from the main library?I'd be happy to open a PR!
The text was updated successfully, but these errors were encountered: