ddekany commented on PR #111:
URL: https://github.com/apache/freemarker/pull/111#issuecomment-2254534147
My reservation is that while `s!?is_blank` is a neat trick, it only solves 1
uses cases out of the 2:
- Use-case 1: `<#if s is null or blank>`, but also, often we need the
opposite, `<#if s is not null, nor blank>`
- With `?is_blank`: `<#if s!?is_blank>`, and the opposite is `<#if
!s!?is_blank>`
- With `?blank_to_null`: `<#if !s?blank_to_null??>`, and the opposite is
`<#if s?blank_to_null??>`
- With `~` operator: `<#if !s~??>`, and the opposite is `<#if s~??>`
- Use-case 2: `get the value of s, but if it's null or blank, then evaluate
to default value 'D'`
- With `?is_blank`: It's doesn't solve the use case (or is way too
verbose).
- With `?blank_to_null`: `s?blank_to_null!'D'`
- With `~` operator: `s~!'D'`
Admittedly in use-case 1 `?is_blank` tells more directly what it wants, but
OTOH `?blank_to_null` reduces the problem to the missing value handling
problem, and so will work with other existing missing value handling mechanism
as well, like macro argument defaults, passing `null` to Java methods, or
anything else that will be added in the future.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]