码迷,mamicode.com
首页 > 其他好文 > 详细

freemarker相关标签

时间:2017-08-26 18:35:31      阅读:115      评论:0      收藏:0      [点我收藏+]

标签:UI   include   输出   html   copyright   地方   逗号   使用   sep   

<#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相关标签

标签:UI   include   输出   html   copyright   地方   逗号   使用   sep   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!