不做浮躁的人
          正在行走的人...
          posts - 171,  comments - 51,  trackbacks - 0
          一:數字型
          <#assign answer=42/>
          ${answer}
          ${answer?string}? <#-- the same as ${answer} -->
          ${answer?string.number}
          ${answer?string.currency}
          ${answer?string.percent}

          <#setting number_format="0.###E0"/>

          ${12345?string("0.####E0")}??


          ${answer?string("number")}?等同于:${answer?string.number}.

          二:日期型:
          預定義格式包括:short?,middle和long。

          ${openingTime?string.short}
          ${openingTime?string.medium}
          ${openingTime?string.long}
          
          組合使用:${lastUpdated?string.short_long}
          ${lastUpdated?string("yyyy-MM-dd HH:mm:ss zzzz")}

          三:邏輯型
          foo?string
          foo?string("yes", "no")

          四:序列的內置方法:
          first

          last

          seq_contains
          ${x?seq_contains("blue")?string("yes", "no")}

          seq_index_of

          seq_last_index_of

          reverse

          size

          sort

          sort_by
          多層次的hash排序

          <#assign members = [
          ??? {"name": {"first": "Joe", "last": "Smith"}, "age": 40},
          ??? {"name": {"first": "Fred", "last": "Crooger"}, "age": 35},
          ??? {"name": {"first": "Amanda", "last": "Fox"}, "age": 25}]>
          Sorted by name.last:
          <#list members?sort_by(['name', 'last']) as m>
          - ${m.name.last}, ${m.name.first}: ${m.age} years old
          </#list>?

          chunk:將一個序列分解成幾個序列。

          <#assign seq = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']>

          <#list seq?chunk(4) as row>
          ? <#list row as cell>${cell} </#list>
          </#list>

          <#list seq?chunk(4, '-') as row>
          ? <#list row as cell>${cell} </#list>
          </#list>
          chunk經常用于分欄或者表格輸出的格式。

          五:hash內置方法:

          keys:
          values:

          六:很少使用或者專家級的內置方法:
          byte,double,float,int,long,short。

          eval

          has_content:變量存在,不是指null也不是空串,一般情況下可以使用expr!?size > 0 or expr!?length > 0 代替expr?has_content

          interpret將一個字符串解析為ftl模版,產生一個TemplateTransformModel對象。
          <#assign x=["a", "b", "c"]>
          <#assign templateSource = "<#list x as y>${y}</#list>">
          <#assign inlineTemplate = templateSource?interpret>
          <@inlineTemplate>def/@inlineTemplate

          is_...檢查變量類型:

          Built-in

          Returns true if the value is a ...

          is_string

          string

          is_number

          number

          is_boolean

          boolean

          is_date

          date (all types: date-only, time-only and date-time)

          is_method

          method

          is_transform

          transform

          is_macro

          macro

          is_hash

          hash

          is_hash_ex

          extended hash (i.e. supports ?keys and ?values)

          is_sequence

          sequence

          is_collection

          collection

          is_enumerable

          sequence or collection

          is_indexable

          sequence

          is_directive

          macro or transform

          is_node

          node


          namespace:返回宏變量的命名空間,只能用于宏。

          new:創建一個TemplateModel實現的變量。
          <#assign word_wrapp = "com.acmee.freemarker.WordWrapperTransform"?new()>
          posted on 2007-03-26 00:04 不做浮躁的人 閱讀(1840) 評論(0)  編輯  收藏 所屬分類: freemarker

          <2007年3月>
          25262728123
          45678910
          11121314151617
          18192021222324
          25262728293031
          1234567

          常用鏈接

          留言簿(9)

          隨筆分類(31)

          隨筆檔案(75)

          文章分類(1)

          文章檔案(3)

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 福建省| 襄城县| 安多县| 山东| 皋兰县| 蓝田县| 建瓯市| 香港| 中西区| 临安市| 宕昌县| 沙田区| 牙克石市| 疏附县| 赤峰市| 于都县| 广东省| 竹北市| 宜兰市| 措美县| 平江县| 长寿区| 秀山| 昭觉县| 江川县| 楚雄市| 田阳县| 桑植县| 新建县| 乡宁县| 高陵县| 三台县| 平山县| 苍梧县| 酉阳| 三门县| 云南省| 大连市| 泗阳县| 从江县| 建水县|