隨筆-124  評論-49  文章-56  trackbacks-0
          1, ?interpret
          能夠將文本的值解析為宏,類似動態指令用法如下
          <#assign x=["a", "b", "c"]>
          <#assign templateSource = "<#list x as y>${y}</#list>">
          <#assign inlineTemplate = templateSource?interpret>
          <@inlineTemplate /> 

          其中"<#list x as y>${y}</#list>"可以是從數據庫中讀取出來的指令


          2, ?new
          創建一個java對象
          <#assign word_wrapp = "com.acmee.freemarker.WordWrapperDirective"?new()>
          還可以在new的時候加參數,如
          <#assign word_wrapp = "com.acmee.freemarker.WordWrapperDirective"?new(40)>

          3, !!和??
          兩個簡寫符號,可以讓我偷電纜(偷點懶)
          ${obj.name!!}  =  ${obj.name?default('')}
          <#if obj?? >   =  <#if obj?exists>


          4, ; in macro 和 nest的參數
          原本以為<#nest/>不能加參數,在構造模板時費了一些勁,原來可以用;在引用macro時給nest傳參數

          <@repeat count=4 ; c, halfc, last>   
            ${c}.${halfc}
          <#if last> Last!</#if>   
          </@repeat>   
          <@repeat count=4 ; c, halfc>   
            ${c}.${halfc}   
          </@repeat>   
          <@repeat count=4>   
            
          Just repeat it   
          </@repeat
          >    

          5, include里的通配符*
          好像可以應對不固定文件夾層級路徑的寫法,但具體沒用過
          <#include "*/footer.ftl">  
          匹配如下
          /foo/bar/footer.ftl
          /foo/footer.ftl
          /footer.ftl

          6    字符串轉換為數字
          <#assign width="234"/>
          <#assign widthNum=width?eval/>

          7  split字符串
          <#assign arr = o[2]?split(',')>
                      
          <#list arr as a>
                      
          <@selArea selName="select1" selId="select1" selvalue=(a?eval) userArea=1010 />
                      
          </#list>

          posted on 2009-11-02 17:41 junly 閱讀(1371) 評論(0)  編輯  收藏 所屬分類: freemark/velocity
          <2009年11月>
          25262728293031
          1234567
          891011121314
          15161718192021
          22232425262728
          293012345

          常用鏈接

          留言簿(4)

          隨筆分類

          隨筆檔案

          收藏夾

          other

          文章

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 景洪市| 清水县| 马山县| 林甸县| 大同市| 龙里县| 桓台县| 奉节县| 北京市| 屏南县| 彭泽县| 焦作市| 青河县| 乌什县| 台东县| 山丹县| 宣化县| 霍州市| 秀山| 红桥区| 临洮县| 玉门市| 永顺县| 韶山市| 乾安县| 横山县| 资中县| 南平市| 大城县| 枝江市| 铜鼓县| 米脂县| 牡丹江市| 东海县| 大理市| 都安| 虹口区| 仙游县| 琼海市| 平武县| 达拉特旗|