FreeMarker设计指南(3)
3、模板<span style="" />(1)整体结构<span style="" />
l 模板使用FTL(FreeMarker模板语言)编写,是下面各部分的一个组合:<span style="" />
Ø 文本:直接输出<span style="" />
Ø Interpolation:由${和},或#{和}来限定,计算值替代输出<span style="" />
Ø FTL标记:FreeMarker指令,和HTML标记类似,名字前加#予以区分,不会输出<span style="" />
Ø 注释:由<#--和-->限定,不会输出<span style="" />
l 下面是以一个具体模板例子:<span style="" />
<div style="padding-right: 8pt; padding-left: 8pt; background: #f0f0f0; padding-bottom: 0cm; padding-top: 0cm; border: #3c78b5 0.75pt dashed;"><span style="font-size: x-small;"><html><span style="font-size: x-small;"><head><span style="font-size: x-small;"> <title>Welcome!</title><span style="font-size: x-small;"></head><span style="font-size: x-small;"><body><span style="font-size: x-small;"> <#-- Greet the user with his/her name --><span style="font-size: x-small;"> <h1>Welcome ${user}!</h1><span style="font-size: x-small;"> <p>We have these animals:<span style="font-size: x-small;"> <ul><span style="font-size: x-small;"> <#list animals as being><span style="font-size: x-small;"> <li>${being.name} for ${being.price} Euros<span style="font-size: x-small;"> </#list><span style="font-size: x-small;"> </ul><span style="font-size: x-small;"></body></html>
页:
[1]