views:

1850

answers:

4

Hi,

FreeMarker templates support an if-statement with the following syntax

<#if hot> 
  It's hot.
</#if>

I've looked in the documentation and can't find any support for an if-else statement. Of course I could achieve the same result with:

<#if hot> 
  It's hot.
</#if>  
<#if !hot> 
  It's not hot.
</#if>

Is support for if-else provided by FreeMarker?

Cheers, Don

+4  A: 

Yes, you can write:

<#if hot>
it's hot
<#else>
it's not
<#/if>

And if you're doing lots of freemarker, I really can recommend IntelliJ IDEA 8, its freemarker support really helps...

Ulf Lindback
+1  A: 

Yes, the sintaxis is:

<#if condition>

...

<#elseif condition2>

...

<#elseif condition3>

...

<#else>

...

<#/if>

You can find Freemarker complete reference

If you are using Netbeans, there is this plugin

iberck
A: 

iberck had already pointed out the docs. But here is the exact documentation about if-else in FreeMarker.

Vijay Dev
Go to the document iberk pointed out, search for if on that page and you get to: http://freemarker.sourceforge.net/docs/ref_directive_if.html
Ulf Lindback
@Ulf: I don't get your point.
Vijay Dev
A: 

thats corrct enjy

chandy