freemarker(5) 操作序列 和 散列

操作序列 和  散列 <br>

<#assign x=["one","two","three","four"]/>
one:${x?seq_contains("one")?string("yes","no")}<br>
  ${x?seq_index_of("one")}<br>
  ${x?seq_last_index_of("one",0)}<br>
  
  <#list x?reverse as num>
           ${num}
  </#list><br>
  
  ${x?size}<br>
  
  
  freemarker   sort,sort_by  排序<br>
  
  <#assign names=["zhangsan","lisi","wangwu"]?sort>
  <#list names as name>
   ${name}<br>
  </#list>
  <br>
  
   <#assign ls=[
     {"name":"zhangsan","age":30}, 
     {"name":"lisi","age":35},
     {"name":"wangwu","age":17}
    ]>
	  <#list ls?sort_by("age") as i>
	  		 ${i.name}---${i.age}<br>
	  </#list>
  <br>
  
  FREEMARKER   chunk  的使用<br>
  
  <#assign seq=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p"]>
  
  <#list seq?chunk(3,"\xA0") as row>
        <#list row as cell>${cell}</#list><br>
  </#list> 
  <br>
  
  <#assign h={"name":"mouse","price":50}>
  <#assign keys=h?keys/>
  <#list keys as key>${key}==${h[key]}<br></#list>
  
  <br>
  <#assign values=h?values>
  <#list values as value>${value}<br></#list>

 

你可能感兴趣的:(C++,c,freemarker,C#,F#)