下载此文档

FreeMarker开发指南初稿.doc


文档分类:办公文档 | 页数:约18页 举报非法文档有奖
1/18
下载提示
  • 1.该资料是网友上传的,本站提供全文预览,预览什么样,下载就什么样。
  • 2.下载该文档所得收入归上传者、原创者。
  • 3.下载的文档,不会出现我们的网址水印。
1/18 下载此文档
文档列表 文档介绍
Freemark 开发指南初稿整理: 蒋江伟 A 概念最常用的 3 个概念 sequence 序列,对应 java 里的 list 、数组等非键值对的集合 hash 键值对的集合 namespace 对一个 ftl 文件的引用, 利用这个名字可以访问到该 ftl 文件的资源 B 指令 if, else, elseif 语法<#if condition >... <#elseif condition2 >... <#elseif condition3 >... ... <#else> ... </#if> 用例<#if x= 1> x is1 </#if> <#if x= 1> x is1 <#else> x is not 1 </#if> switch, case, default, break 语法<#switch value ><#case refValue1 >... <#break> <#case refValue2 >... <#break> ... <#case refValueN >... <#break> <#default> ... </#switch> 用例字符串<#switch > <#case "small"> This will be processed if it is small <#break> <#case "medium"> This will be processed if it is medium <#break> <#case "large"> This will be processed if it is large <#break> <#default> This will be processed if it is neither </#switch> 数字<#switch x> <#case x= 1> 1 <#case x= 2> 2 <#default> d </#switch> 如果 x=1 输出 1 2, x=2 输出 2, x=3 输出 d list, break 语法<#list sequence asitem >... <#if item = "spring"> <#break> </#if> ... </#list> 关键字 item_index: 是list 当前值的下标 item _has_next :判断 list 是否还有值用例<#assign seq = ["winter", "spring", "summer", "autumn"]> <#list seq as x> ${ x_index + 1}. ${x}<#if x_has_next >,</#if> </#list> 输出 1. winter, 2. spring, 3. summer, 4. autumn include 语法<#include filename >or<#include filename options > options 包含两个属性 encoding =”GBK ”编码格式 parse =true 是否作为 ftl 语法解析,默认是 true ,false 就是以文本方式引入. 注意在ftl文件里布尔值都是直接赋值的如parse=true, 而不是parse= ”true ”用例/common/ 包含内容 Copyright 2001-2002 ${me}<br> All rights reserved. 模板文件<#assign me= "Juila Smith"> <h1>Some test</h1> <p>Yeah. <hr> <#include "/common/" encoding= ” GBK ”> 输出结果<h1>Some test</h1> <p>Yeah. <hr> Copyright 2001-2002 Juila Smith All rights reserved. Import 语法<#import path ashash > 类似于 java 里的 import, 它导入文件,然后就可以在当前文件里使用被导入文件里的宏组件用例假设 里定义了宏 copyright 那么我们在其他模板页面里可以这样使用<#import "/libs/" as my> <***@ date="1999-2002"/> " my"在 freemarker 里被称作 press 语法<#compress> ... </#compress> 用来压缩空白空间和空白的行用例<#assign x=" moo \n\n "> (<#compress>

FreeMarker开发指南初稿 来自淘豆网www.taodocs.com转载请标明出处.

相关文档 更多>>
非法内容举报中心
文档信息
  • 页数18
  • 收藏数0 收藏
  • 顶次数0
  • 上传人luyinyzhi
  • 文件大小130 KB
  • 时间2017-02-24