【发布时间】:2012-09-04 12:30:09
【问题描述】:
在速度方面,我有一个变量,其值为 null。在这种情况下,我不想显示任何内容。
目前模板引擎将 "" 翻译成 null 所以我必须这样做。
#set ( $a = "")
#if ($a)
assert("never prints a neither gets here: " + $a)
#end
有没有办法直接做到这一点?我希望能够做出类似的东西:
This is the variable $a. ## in case that $a is null i don't want 'dollar a' to be displayed
【问题讨论】:
-
您可能会发现以下 Velocity wiki 页面很有趣:Checking for null。另请查看$null check in velocity