首页 > 其他 > 详细

freemarker相关标签

时间:2017-08-26 18:05:32      阅读:272      评论:0      收藏:0      [点我收藏+]

<#if animals.python.price != 0>

       Pythons are not free today!

</#if>

 

<#if animals.python.price < animals.elephant.price>

           Pythons are cheaper than elephants today.

<#elseif animals.elephant.price < animals.python.price>

          Elephants are cheaper than pythons today.

<#else>

          Elephants and pythons cost the same today.

</#if>

 

上面示例中的一个问题是如果我们有0个水果,它仍然会输出一个空的 <ul></ul>,而不是什么都没有。 要避免这样的情况,可以这么来使用 list

<#list misc.fruits>

  <ul>

      <#items as fruit>

          <li>${fruit}

     </#items>

</ul>

</#list>

 

被 sep 覆盖的部分(我们也可以这么来写: ...<#sep>, </#sep></#list>) 只有当还有下一项时才会被执行。 因此最后一个水果后面不会有逗号:

<p>Fruits:

 <#list misc.fruits as fruit>

        ${fruit}<#sep>,

</#list>

 

假设要在一些页面中显示版权声明的信息。那么可以创建一个文件来单独包含这些版权声明, 之后在需要它的地方插入即可,

当需要用到文件时,可以使用 include 指令来插入:

<#include "/copyright_footer.html">

freemarker相关标签

原文:http://www.cnblogs.com/wangyaobk/p/7435833.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!