Welcome Big Joe!
Our latest product:
(2)数据模型
l 典型的数据模型是树型结构,可以任意复杂和深层次,如下面的例子: (root) |
+- animals | |
| +- mouse | | |
| | +- size = \ | | |
| | +- price = 50 | |
| +- elephant | | |
31
| | +- size = \ | | |
| | +- price = 5000 | |
| +- python | |
| +- size = \ | |
| +- price = 4999 |
+- test = \ |
+- whatnot |
+- because = \
l 类似于目录的变量称为hashes,包含保存下级变量的唯一的查询名字 l 类似于文件的变量称为scalars,保存单值
l scalars保存的值有两种类型:字符串(用引号括起,可以是单引号或双引号)和数字(不要用引号将数字括起,这会作为字符串处理)
l 对scalars的访问从root开始,各部分用“.”分隔,如animals.mouse.price l 另外一种变量是sequences,和hashes类似,只是不使用变量名字,而使用数字索引,如下面的例子:
32
(root) |
+- animals | | | +- (1st) | | |
| | +- name = \ | | |
| | +- size = \ | | |
| | +- price = 50 | | | +- (2nd) | | |
| | +- name = \ | | |
| | +- size = \ | | |
| | +- price = 5000 | | | +- (3rd) | |
33
| +- name = \ | |
| +- size = \ | |
| +- price = 4999 |
+- whatnot | +- fruits |
+- (1st) = \ |
+- (2nd) = \
l 这种对scalars的访问使用索引,如animals[0].name (3)模板
l 在FreeMarker模板中可以包括下面三种特定部分:
? ${…}:称为interpolations,FreeMarker会在输出时用实际值进行替代
? FTL标记(FreeMarker模板语言标记):类似于HTML标记,为了与HTML标记区分,用#开始(有些以@开始,在后面叙述)
? 注释:包含在<#--和-->(而不是)之间 l 下面是一些使用指令的例子: ? if指令
34
<#if animals.python.price < animals.elephant.price> Pythons are cheaper than elephants today. <#else>
Pythons are not cheaper than elephants today. #if>
? list指令
We have these animals:
${being.name}${being.price} Euros #list> 输出为:
We have these animals:
? include指令
35