elseif Block

Does the Percussion velocity templates support else if statement. Can we write something like this:

if(condition1){
//Do Something
}
elseif (condition 2){
//Do Something
}elseif (condition 3){
//Do Something
}else{
//Do Something
}

Or it has to be in the format:

if (condition 1){
//Do Something
}else{
if (condition 2){
//Do Something
}else{
if (condition 3){
//Do Something
}else{

            }
      }

}

Are you using velocity or jexl in a binding or location scheme? Because the syntax is different.

This is a snippet from the Velocity User Guide:

#if( $foo < 10 )
    <strong>Go North</strong>
#elseif( $foo == 10 )
    <strong>Go East</strong>
#elseif( $bar == 6 )
    <strong>Go South</strong>
#else
    <strong>Go West</strong>
#end

If JEXL in a binding or location scheme:

if ((x * 2) == 5) {
    y = 1;
} else if(x == 5){
    y = 2;
}

Also look at this post. The final solution gives an example of else if.


        if($sys.crossSiteLink && $sys.variables.rxs_subroot != 'none'){$prefix = $sys.site.url + $sys.variables.rxs_subroot;}else if($sys.crossSiteLink && $sys.variables.rxs_subroot == 'none'){$prefix = $sys.site.url;}else if(!$sys.crossSiteLink && $sys.variables.rxs_subroot != 'none'){$prefix = $sys.variables.rxs_subroot;}else{$prefix='';} $prefix + $sys.pub_path;