I have the following piece of code in my template that uses NVelocity to process form data:

$PartnerProfile.Nvalue("Name")

In case the Nvalue method doesn't return any value, I want NVelocity to display nothing. But it rather outputs the code, i.e.
"Lorem ipsum dolor sit $PartnerProfile.Nvalue("Name") amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt"

How can I prevent that code to be displayed in my output?

有帮助吗?

解决方案

The answer is very simple. I just need to add the character '!' to the beginning of the token. Like this:

$!PartnerProfile.Nvalue("Name")

The output in case there's no value for the indicated parameter will be empty.

"Lorem ipsum dolor sit $PartnerProfile.Nvalue("Name") amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt"

will be this -->

"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt"

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top