Adjust documentation on Iff (#179)
1 file changed, 6 insertions(+), 4 deletions(-)
changed files
M gomponents.go → gomponents.go
@@ -254,8 +254,8 @@ } // If condition is true, return the given Node. Otherwise, return nil. // This helper function is good for inlining elements conditionally. -// If your condition and node involve a nilable variable, use iff because -// go will evaluate the node regardless of the condition. +// If it's important that the given Node is only evaluated if condition is true +// (for example, when using nilable variables), use [Iff] instead. func If(condition bool, n Node) Node { if condition { return n@@ -263,8 +263,10 @@ } return nil } -// Iff execute the function f if condition is true, otherwise return nil. -// it is the preferred way to conditionally render a node if the node involves a nilable variable. +// Iff condition is true, call the given function. Otherwise, return nil. +// This helper function is good for inlining elements conditionally when the node depends on nilable data, +// or some other code that could potentially panic. +// If you just need simple conditional rendering, see [If]. func Iff(condition bool, f func() Node) Node { if condition { return f()