views:

36

answers:

1

This is a piece of my freemarker template:

${order.needByDate?if_exists?date}

I want it to work as following:

  • if needByDate is null, then write nothing
  • if it is not null, then write the date part

The above works only in second scenario. What is the correct way to achieve this?

A: 

There may be a smarter way of doing this but the following should do the job.

<#if order.needByDate??>${order.needByDate?date}</#if>
cherouvim