Display nothing rather than link when field not set

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.

Hi! You can use Velocity quiet notation: The quiet notation includes the ! and means to output nothing if the reference does not exist.

    #if ('' != "$!value")

So, in the end you have: if value is not null and the value is not empty.