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
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 default, which is great, but limited). For example, let's say that for a certain page type I want to use the parent'sParams for some stuff in my template. Currently, AFAIK I'd need to use a scratch variable:
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.
The text was updated successfully, but these errors were encountered:
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
default
, which is great, but limited). For example, let's say that for a certain page type I want to use the parent'sParams
for some stuff in my template. Currently, AFAIK I'd need to use a scratch variable: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.
The text was updated successfully, but these errors were encountered: