Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Ternary operator-like function #3860
TL;DR: I'd like a function similar to the ternary operator in C-like languages.
One thing I've found a bit frustrating with go templates is that you can't really conditionally assign to a variable (other than with
What I'd like to do is something like
I'm not overly fond of the name "ternary" since not everyone writing Hugo themes is likely to be familiar enough with a C-like language to even know about the ternary operator. Maybe "when" would make sense, or "cond"? I don't really care about the name, though.