<#--
判断字符是否为null或者""
-->
<#function isCZ text="">
<#if text=="" || !text??>
<#return false>
<#else>
<#return true>
</#if>
</#function>
<#--
时间日期格式化
格式为:yyyy-MM-dd hh:mm
-->
<#function dateFormartTime date>
<#if date?exists>
<#return date?string("yyyy-MM-dd hh:mm")>
<#else>
<#return "时间为空!">
</#if>
</#function>
<#--
字符合理长度截取,传入字符小于截取位置将返回
原字符,大于将截取字符串
@param txt 需要截取的字符串
@param size 截取字符串的长度
-->
<#function sb txt='' size=0>
<#if txt?exists>
<#if (txt?length>size)>
<#return txt?substring(0,size)>
<#else>
<#return txt>
</#if>
<#else>
<#return "">
</#if>
</#function>
<#--
@auther loowj 2012-12-12
@Param map 数据Map
@Param 获取的key
@Param position 传入则代表key传入取的是list,取position位置上的元素
-->
<#function getMapDataByKey map key position="null">
<#if map[key]??>
<#assign list = map[key]![]>
<#if position != "null">
<#list list as obj>
<#if obj_index == position>
<#return obj>
</#if>
</#list>
<#return {}>
</#if>
<#return list>
<#else>
<#return {}>
</#if>
</#function>
<#--
最大支持5个占位符替换的模板
-->
<#function urlBuild a b c d e f='' urlTemplate="{a}.{b}.{c}/{d}-{e}/">
<#assign tempUrl= urlTemplate>
<#if isCZ(a)>
<#assign tempUrl=tempUrl?replace("{a}",a)>
</#if>
<#if isCZ(b)>
<#assign tempUrl=tempUrl?replace("{b}",b)>
</#if>
<#if isCZ(c)>
<#assign tempUrl=tempUrl?replace("{c}",c)>
</#if>
<#if isCZ(d)>
<#assign tempUrl=tempUrl?replace("{d}",d)>
</#if>
<#if isCZ(e)>
<#assign tempUrl=tempUrl?replace("{e}",e)>
</#if>
<#if isCZ(f)>
<#assign tempUrl=tempUrl?replace("{f}",f)>
</#if>
<#return tempUrl>
</#function>