Albert Kam
2013-07-30 09:51:37 UTC
I am currently using some macros that can accept a param, which can be
string or sequence like this :
<#macro test param>
</#macro>
But i want the param to be optional, so, i want to put a default value on
it, and check whether the param is specified or not :
<#macro test param="">
<#if notEmptyString(param)>
....
<#else>
....
</#if>
</#macro>
And here's my function on checking the emptiness of the param :
<#function notEmptyString value>
<#return !(value?is_string) || value != "">
</#function>
Altough i havent faced any problems yet, i have my own doubts with this
function, since the param can be of multiple types which will pass the
?is_string. If so, how do i do the checking correctly ?
Thank you ..
string or sequence like this :
<#macro test param>
</#macro>
But i want the param to be optional, so, i want to put a default value on
it, and check whether the param is specified or not :
<#macro test param="">
<#if notEmptyString(param)>
....
<#else>
....
</#if>
</#macro>
And here's my function on checking the emptiness of the param :
<#function notEmptyString value>
<#return !(value?is_string) || value != "">
</#function>
Altough i havent faced any problems yet, i have my own doubts with this
function, since the param can be of multiple types which will pass the
?is_string. If so, how do i do the checking correctly ?
Thank you ..
--
Do not pursue the past. Do not lose yourself in the future.
The past no longer is. The future has not yet come.
Looking deeply at life as it is in the very here and now,
the practitioner dwells in stability and freedom.
(Thich Nhat Hanh)
Do not pursue the past. Do not lose yourself in the future.
The past no longer is. The future has not yet come.
Looking deeply at life as it is in the very here and now,
the practitioner dwells in stability and freedom.
(Thich Nhat Hanh)