初试freemarker->进阶(三)

初试freemarker->进阶(三)

一、t  It  rt  nt 指令
<#t> 去掉左右空白和回车换行
<#It> 去掉左边空白和换行
<#rt> 去掉右边空白和换行
<#nt> 取消上面的效果

、 nested指令

<#nested>指令可以被多次调用,每次都会执行相同的内容。
ftl文件内容:
<#macro do_thrice>
  <#nested>
  <#nested>
  <#nested>
调用宏:
<@do_thrice>
  Anything.
</@do_thrice>
 输出结果:
Anything.
Anything.
Anything.

三、 Interpolation
通用Interpolation 用${expre}表示,数字专用Interpolation 用 #{expre}或 #{expre;format}
事例代码 :
<#setting number_format="percent"/>
<#assign num=10/>
${num}
${num?string.number}
${num?string.percent}
${num?string.cutrrency}
结果为 :1000%  10   1000%   ¥10.00
当 expre为日期时,会根据setting指令确定格式
<#--由setting指令确定-->
<#setting date_format="yyyy-MM-dd HH:mm:ss zzzz">
现在时间为:${nowDate?date?string}<br>
<#--由内置的转换格式确定-->
现在的时间为 :${nowDate?datetime?string.short}<br>
现在的时间为 :${nowDate?datetime?string.long}<br>
<#--自己指定日期-->
现在的时间为 :${nowDate?string("EEEE,MMM d,yy")}<br>
上面的输出为:
现在的时间为 :2008-05-02 09:48:33 中国标准时间
现在的时间为 :08-5-2 上午9:48
现在的时间为 :2008年5月2日 上午09时48分33秒
现在的时间为 :星期五,五月 2,08

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值