Velocity: Is a any way to check if variable is defined

sergtk picture sergtk · Jan 28, 2011 · Viewed 29.5k times · Source

I want to include one template nested into others cont1, cont2, cont3. And nested template should be hide one specific control for cont1 only. Before inclusion into cont1 I would like to assign value to some flag variable $hideMyControl.

And inside nested template I would like to check if $hideMyControl is assigned value.

How to perform such check?

Answer

onlinehood picture onlinehood · Feb 14, 2013
#if($hideMyControl)
    // your code
#end

If $hideMyControl is defined, your code will execute