Test code
@Test publicvoid test06 () { try { root.put ("emp "," <span color= ' red ' > Hello Zhang San </span> "); "06.FTL"); " 06.FTL ", fn+" 06.html "); Catch (Exception e) { e.printstacktrace (); } }
FTL template files
<Body>${emp}<BR/><#--display text-->${emp?html}<BR/><#--Display HTML text--> <#assigna= "BC"><#--Remove the trailing spaces->a${a?trim}d<BR/> <#--capital letters, all lowercase, all uppercase--> <#assignx= "AbC">${x?cap_first}<#--First Letter lowercase-->${x?lower_case}<#--all lowercase-->${x?upper_case}<#--All caps--> <BR/> <#--define an array--> <#assignNums=["1", "2", "3"]/>${nums?size}<#listnums as Num>A.${num}</#list> <BR/> <#--can only be two points--> <#assignNums=1..10/> <#listnums as Num>B.${num}</#list> <BR/> <#--Direct Traversal--> <#listnums[0..9] as num>C.${num}</#list> <BR/> <#--string interception-->${"The river flows eastward" [0..3]}<BR/> <#--This content can be seen in the document processing hash table built-in function--> <#--directly take out the map value--> <#assignUsers={"A": "Zhang San", "B": "John Doe"}/>${users["A"]} ${USERS.A}<BR/> <#--looping through a map requires the key to be taken out first-> <#assignKeys=users?keys/> <#listKeys as key>${key}---${users["${key}"}---${users[key]}</#list></Body>
Effect
"Freemaker" text, HTML text, remove space, letter case, loop array, string intercept, map value, traverse map