tpl/compare: Use any data type for compare.Conditional condition

Improves #5792
This commit is contained in:
Joe Mooring
2024-09-20 13:13:02 -07:00
committed by Bjørn Erik Pedersen
parent 1e690c0f23
commit 0ea796dad1
2 changed files with 30 additions and 8 deletions

View File

@@ -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