## [{a:1, b:2}, {a:2, b:3}] 形式 #macro(objects $bar $keys) [ \#foreach($foo in $bar) { #foreach($key in $keys) "$key" : "\$foo.$key" #if($velocityCount < $keys.size()) , #end #end } \#if($velocityCount < ${bar}.size()) , \#end \#end ] #end #macro(lists $lists) [ \#foreach($key in $lists) "$key" \#if($velocityCount < ${lists}.size()) , \#end \#end ] #end #macro(maps $maps) { \#foreach($list in ${maps}.entrySet()) "$list.key" : "$list.value" \#if($velocityCount < ${maps}.size()) , \#end \#end } #end ##method #macro(method $args $ret) { "__isMethod": true, "callMap": [ { "arguments": [$args], "return" : "$ret" } ] } #end #if($macro == 'maps') #maps($vmText) #elseif($macro == 'method') #method($vmText $third) #elseif($macro == 'lists') #lists($vmText) #elseif($macro == 'objects') #objects($vmText $third) #elseif($macro == 'string') "$vmText" #end