joinClasses
Joins all given classes strings to one html-class-attribute String. Individual Strings that are null or blank are filtered out.
Examples
val classes = joinClasses(
"class1",
null,
"class2",
""
)
println(classes) // prints "class1 class2"
Content copied to clipboard
Using this function, it is also possible to conditionally construct classes strings without having to do dangerous string concatenation:
val classes = joinClasses(
"class1",
"class2".takeIf { it.length 10 }
)
println(classes) // prints "class1"
Content copied to clipboard