[
https://issues.apache.org/jira/browse/FREEMARKER-21?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15864381#comment-15864381
]
Daniel Dekany commented on FREEMARKER-21:
-----------------------------------------
`(exp)\!exp` is special, in that it allows the exception to be raised.
`absent?has_content` doesn't raise an exception anywhere, nor `absent!'Good
bye'` doesn't either. The way it works is that something evaluating to
"missing" (to Java `null` on the lower level) is not an error in itself. The
exception is raised when you try to do something with that missing value
(`null`), and that operation, like outputting it, or `#assign` it to something,
doesn't allow `null`-s. And almost nothing allows `null`-s in FreeMarker 2, but
of course things that were specifically made to deal with missing values (such
as `?has_content`) do. So this is what we have to work with in FM2. (I want it
to be different in FM3.)
> Reference to the object in condition - avoid repeating the same in #if and
> ${...}
> ---------------------------------------------------------------------------------
>
> Key: FREEMARKER-21
> URL: https://issues.apache.org/jira/browse/FREEMARKER-21
> Project: Apache Freemarker
> Issue Type: New Feature
> Components: engine
> Reporter: Ondra Žižka
>
> Repeating stuff is annoying, especially in programming.
> Therefore this is annoying:
> {code}
> <#if someVariable.someMethod.someProperty??>
> <div>${someVariable.someMethod.someProperty}</div>
> </#if>
> {code}
> This would be better:
> {code}
> <#if someVariable.someMethod.someProperty?? as value>
> <div>${value}</div>
> </#if>
> {code}
> Not talking about the fact that it could only be evaluated once.
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)