Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 23F3A200C3E for ; Mon, 13 Feb 2017 13:22:32 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 22BC9160B6C; Mon, 13 Feb 2017 12:22:32 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 741B4160B72 for ; Mon, 13 Feb 2017 13:22:31 +0100 (CET) Received: (qmail 40165 invoked by uid 500); 13 Feb 2017 12:20:20 -0000 Mailing-List: contact notifications-help@freemarker.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@freemarker.incubator.apache.org Delivered-To: mailing list notifications@freemarker.incubator.apache.org Received: (qmail 36461 invoked by uid 99); 13 Feb 2017 12:20:16 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 13 Feb 2017 12:20:16 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id B431FC7041 for ; Mon, 13 Feb 2017 12:20:15 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -1.199 X-Spam-Level: X-Spam-Status: No, score=-1.199 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RP_MATCHES_RCVD=-2.999] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id zlFT7DpelCNO for ; Mon, 13 Feb 2017 12:20:15 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTP id 532A76135E for ; Mon, 13 Feb 2017 12:19:34 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 3F5ACE0DA5 for ; Mon, 13 Feb 2017 12:19:24 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id A9FD62248E for ; Mon, 13 Feb 2017 09:32:41 +0000 (UTC) Date: Mon, 13 Feb 2017 09:32:41 +0000 (UTC) From: "Daniel Dekany (JIRA)" To: notifications@freemarker.incubator.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (FREEMARKER-21) Reference to the object in condition - avoid repeating the same in #if and ${...} MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Mon, 13 Feb 2017 12:22:32 -0000 [ https://issues.apache.org/jira/browse/FREEMARKER-21?page=3Dcom.atlass= ian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=3D1= 5863386#comment-15863386 ]=20 Daniel Dekany commented on FREEMARKER-21: ----------------------------------------- In {{(foo as bar)!"Hello!"}} the assignment to {{bar}} simply wouldn't happ= en, since evaluating {{foo}} basically causes an exception which is then ha= ndled by the {{(...)!exp}}. Confusing, I know, but the intended use is the = opposite, that is, we use the `as`-ed (or, well, `into`-ed) variable when i= ts left side has existed. As of handling missing values in FreeMarker, the problems of it (particular= ly when it comes to assigning things) are known, but I don't think we can d= o much about it in FreeMarker 2. It was made like this 14 years ago or so, = and you simply can't break backward compatibility that much in 2.x, because= that means that tons of projects can't update FreeMarker anymore. That's w= hy FreeMarker 3 was started not long ago, and there the point is to move in= to another package (so it doesn't interfere with FreeMarker 2) and break ba= ckward compatibility and do what's right. But if 3 ever comes out one day, = FreeMarker 2 will remain with us for a long time... > Reference to the object in condition - avoid repeating the same in #if an= d ${...} > -------------------------------------------------------------------------= -------- > > Key: FREEMARKER-21 > URL: https://issues.apache.org/jira/browse/FREEMARKER-21 > Project: Apache Freemarker > Issue Type: New Feature > Components: engine > Reporter: Ondra =C5=BDi=C5=BEka > > Repeating stuff is annoying, especially in programming. > Therefore this is annoying: > {code} > <#if someVariable.someMethod.someProperty??> >
${someVariable.someMethod.someProperty}
> > {code} > This would be better: > {code} > <#if someVariable.someMethod.someProperty?? as value> >
${value}
> > {code} > Not talking about the fact that it could only be evaluated once. -- This message was sent by Atlassian JIRA (v6.3.15#6346)