-
-
Notifications
You must be signed in to change notification settings - Fork 7.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve the cond func #5792
Comments
@bep I would love to give it a try 👏 I'm new here 🔰 |
@jamesgeorge007 this is a particulary hard problem. I don't know how to do it myself. |
One line is always better than 4, especially in Go Template.
|
@bep @regisphilibert if that's the case, can you point me to something that is good to start with 👏 |
Given:
@bep, as I under the existing implementation, it would blow up if |
@moorereason It would 2 days ago ... I changed it from a pointer to a struct (which is how was in 0.54) for a very similar reason. But you are right, there are (at least) 2 reasons why I want to fix this:
The problem, I have no idea how to do this without making modifications to Go's stdlib, so I might bring it up with them (would not be too hopeful). Because now:
(same with Is very different from: if .Foo && .Bar {
} |
I think any help from the Go stdlib in this area is long down the road. But for
Becomes
Or similar. |
The behavior of `truth` and `bool` is described in the corresponding test cases and examples. The decision-making around the behavior is a based on combination of the existing behavior of strconv.ParseBool in go and the MDN definition of "truthy" as JavaScript has the most interop with the Hugo ecosystem. Addresses gohugoio#9160 and (indirectly) gohugoio#5792
There are two items that I want to address:
Basically I want to be able to do something ala:
Maybe not the best example, but imagine a nilpointer scenario etc.
The text was updated successfully, but these errors were encountered: