隨筆-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

          文章

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 宜兴市| 五华县| 澎湖县| 怀安县| 旌德县| 哈巴河县| 房山区| 始兴县| 迭部县| 鲁山县| 台江县| 当雄县| 夏河县| 固阳县| 延庆县| 达尔| 博乐市| 文安县| 英超| 沛县| 依安县| 湟中县| 万山特区| 安化县| 确山县| 枝江市| 如皋市| 高雄市| 漳州市| 鄂伦春自治旗| 荆州市| 育儿| 孝昌县| 托里县| 长宁区| 祁阳县| 太白县| 宁夏| 吕梁市| 新密市| 永定县|