Details
-
Type:
Improvement
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: None
-
Fix Version/s: 1.5
-
Component/s: None
-
Labels:None
-
Number of attachments :
Description
For GroovyTemplates its not very desirable to have alot of "null" printed everywhere we might have included a possible null value. So it would be nice to have a way to make GString print "" instead of null.
Velocity does that via $!
{text}which I think is ok, but we may just parse the Template text and always "insert" $
{(text == null) ? "" : text"}since I think its always the desired behaviour for gstrings to not print null (within Templates).
Issue Links
- duplicates
-
GROOVY-481
Consider enhancing default string templates to support $foo or $!{foo}
-
- is depended upon by
-
GROOVY-753
complete parser
-
What about just making it such that GroovyTemplates (possibly optionally) don't print nulls.
Its very amateurish when websites print nulls all over the place.
Especially with the null safe method invocations, it would be nice to be able to use.
$
{user->lastLogin}Another thought, would be to use an OR, since this will let you give an alternative.
$
{user->lastLogin || "Never Logged In"}But I don't think this will work, since || quite rightly is a boolean expression, even though "if (a)" works.
1> print (a || "b")
2> execute
true