proposal: hasField
function for use with structs
#60
Labels
aspect/dex 🤖
Concerns developers' experience with the codebase
domain/obvious 🟩
Represents the "known knowns" issue. It's Obviously
good first issue
Good for newcomers
priority/low 🟩
Priority 4 - Low priority and doesn't need to be rushed
state/todo 🚀
This is confirmed, will work on soon
state/triage 🚦
Has not been triaged & therefore, not ready for work
type/feature ⭐
Addition of new feature
You have a proposal, explain it!
Originally proposed here: Masterminds/sprig#401
I 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:Full code example
Describe the solution you'd like
I took the
hasField
method implementation from the following StackOverflow thread: Field detection in Go HTML template.It looks like this:
I feel something similar can be added to the
reflect
registry, so it can be used with Sprout out of the box.I'd be happy to open a PR!
Additional context
No response
Code of Conduct
The text was updated successfully, but these errors were encountered: