Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

$null check in velocity

I came to know about null check using $null in velocity 1.6 through a resource updated by you. Resource: Reading model objects mapped in Velocity Templates But I am facing so many challenges that there is no $null for null check in velocity as there is no documentation provided about this. Please provide me with documentation stating $null as valid for null check in velocity.

Thanks in Advance lucky

like image 329
lucky Avatar asked Aug 13 '10 16:08

lucky


People also ask

What is velocity .VM file?

Developer file used by Velocity, a Java-based template engine; written using the Velocity Template Language (VTL); contains VTL statements inserted in a normal text document; often used for auto-generating Web source code and class skeletons.

How do you check if a value is blank?

Sometimes you need to check if a cell is blank, generally because you might not want a formula to display a result without input. In this case we're using IF with the ISBLANK function: =IF(ISBLANK(D2),"Blank","Not Blank")


1 Answers

To check if a variable is not null simply use #if ($variable)

 #if ($variable)   ... do stuff here if the variable is not null #end 

If you need to do stuff if the variable is null simply negate the test

 #if (!$variable)  ... do stuff here if the variable is null #end 
like image 56
a_horse_with_no_name Avatar answered Sep 20 '22 19:09

a_horse_with_no_name