Re: [FreeMarker-user] FW: crud screens and null.
Generates text that depends on changing data (like dynamic HTML).
Brought to you by:
revusky
|
From: Daniel D. <dd...@fr...> - 2006-05-09 14:22:37
|
Tuesday, May 9, 2006, 3:58:20 PM, Daniel Dekany wrote:
> Tuesday, May 9, 2006, 3:16:12 PM, Payne, Matthew wrote:
>
>> +1
>>
>> Support the ?!?.
This was: Support the "!"
> I disagree. The ! of Velocity doesn't let you specify the default
> value, so what should the template language do with the "suppressed"
> null then?
>
> But, I agree that ?default(exp) needs a shorter form. Say, let it be:
> exp!theDefaultExp and (exp)!theDefaultExp. With examples:
>
> ${maidenName!'N/A'}
>
> ${(user.name)!'anonymous'}
A further note to this for those who come from Velocity: the usage of
?default(exp) is not limited to interpolations at all. It is a generic
way to handle when a variable is missing, no mater where is the
expression used. So by using ?default(x), or rather its proposed
shorthand form, you can write thing like:
<#if item.radiation!0 > 100>Lead-lining must be used!</#if>
Where the radiation of items where it is not specified defaults to 0
Bq.
> Also ?string needs a shorter form, like ${x~#.000}.
(This last was in the TODO tracker for years... before Jonatahn asks
if I already proposed this. Only for 10 times or so... :) (The
shorthand default value is the part of all "new template language"
designs for years too, although I used ? instead of ! and have
eliminated the built-ins feature altogether. None of these were ever
published however.))
--
Best regards,
Daniel Dekany
|