문제

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