mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-19 21:21:39 +02:00
tpl/compare: Use any data type for compare.Conditional condition
Improves #5792
This commit is contained in:
committed by
Bjørn Erik Pedersen
parent
1e690c0f23
commit
0ea796dad1
@@ -231,8 +231,8 @@ func (n *Namespace) checkComparisonArgCount(min int, others ...any) bool {
|
||||
// Conditional can be used as a ternary operator.
|
||||
//
|
||||
// It returns v1 if cond is true, else v2.
|
||||
func (n *Namespace) Conditional(cond bool, v1, v2 any) any {
|
||||
if cond {
|
||||
func (n *Namespace) Conditional(cond any, v1, v2 any) any {
|
||||
if hreflect.IsTruthful(cond) {
|
||||
return v1
|
||||
}
|
||||
return v2
|
||||
|
Reference in New Issue
Block a user