freemarker-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Pedro M. Zamboni (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (FREEMARKER-21) Reference to the object in condition - avoid repeating the same in #if and ${...}
Date Sun, 12 Feb 2017 23:57:41 GMT

    [ https://issues.apache.org/jira/browse/FREEMARKER-21?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15863043#comment-15863043
] 

Pedro M. Zamboni commented on FREEMARKER-21:
--------------------------------------------

Since the right‐hand‐side of the {{as}} clause in {{list}} isn’t an expression, I can’t
see how this would introduce an ambiguity. It should be easy to simply consider the last {{as}}
in the expression as the one that is part of the {{list}} syntax, and the rest as creating
a new variable.

Either way, I can’t really say I like this feature. It’s not like declaring a variable
is too hard:

{code}
<#local value=someVariable.someMethod.someProperty>
<#if value??>
    ${value}
</#if>
{code}

It seems to me that this feature will help decrease code readability, as you can have {{as}}
deep inside a complex expression.

> 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)

Mime
View raw message