I have a field that’s displayed in a link, but when the field value is an empty string, I don’t want to display anything. So I wrote this macro:#macro(optionalLink $dir $value)
#if ($value != ‘’’)
[[$dir.$value]]##
#else
## if value is empty, show an empty cell
#end
#end
…so that can just say…
#optionalLink(‘Somedir’, $person.name)
…rather than…
#if ($person.name != ‘’’)
[[$dir.$value]]##
#end
Is there an easier way? The “!” operator doesn’t do what I want. Seems like there could be some built-in syntax or something in the Velocity API Tools, but I don’t see anything.