简体   繁体   English

FreeMarker模板中的if-else

[英]if-else in FreeMarker template

FreeMarker templates support an if-statement with the following syntax FreeMarker模板支持使用以下语法的if语句

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

I've looked in the documentation and can't find any support for an if-else statement. 我查看了文档,找不到if-else语句的任何支持。 Of course, I could achieve the same result with: 当然,我可以通过以下方式获得相同的结果:

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

Is there support for if-else in FreeMarker? 在FreeMarker中是否支持if-else?

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... 如果你做了很多freemarker,我真的可以推荐IntelliJ IDEA 8,它的freemarker支持确实有帮助......

Yes, the sintaxis is: 是的,sintaxis是:

<#if condition>

...

<#elseif condition2>

...

<#elseif condition3>

...

<#else>

...

<#/if>

You can find Freemarker complete reference 你可以找到Freemarker完整参考

If you are using Netbeans, there is this plugin 如果您使用的是Netbeans,则会有此插件

iberck had already pointed out the docs. iberck已经指出了这些文档。 But here is the exact documentation about if-else in FreeMarker . 但这里有关于FreeMarker中if-else的确切文档。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM