Return-Path: Delivered-To: apmail-velocity-dev-archive@www.apache.org Received: (qmail 67721 invoked from network); 6 Oct 2008 02:56:35 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 6 Oct 2008 02:56:35 -0000 Received: (qmail 53814 invoked by uid 500); 6 Oct 2008 02:56:33 -0000 Delivered-To: apmail-velocity-dev-archive@velocity.apache.org Received: (qmail 53797 invoked by uid 500); 6 Oct 2008 02:56:33 -0000 Mailing-List: contact dev-help@velocity.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Velocity Developers List" Delivered-To: mailing list dev@velocity.apache.org Received: (qmail 53786 invoked by uid 500); 6 Oct 2008 02:56:33 -0000 Delivered-To: apmail-jakarta-velocity-dev@jakarta.apache.org Received: (qmail 53783 invoked by uid 99); 6 Oct 2008 02:56:33 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 05 Oct 2008 19:56:33 -0700 X-ASF-Spam-Status: No, hits=-1998.7 required=10.0 tests=ALL_TRUSTED,DNS_FROM_DOB,DNS_FROM_SECURITYSAGE,RCVD_IN_DOB X-Spam-Check-By: apache.org Received: from [140.211.11.140] (HELO brutus.apache.org) (140.211.11.140) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 06 Oct 2008 02:55:38 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 3BFDC234C211 for ; Sun, 5 Oct 2008 19:55:44 -0700 (PDT) Message-ID: <116988852.1223261744244.JavaMail.jira@brutus> Date: Sun, 5 Oct 2008 19:55:44 -0700 (PDT) From: "Byron Foster (JIRA)" To: velocity-dev@jakarta.apache.org Subject: [jira] Updated: (VELOCITY-618) Strict property and method references In-Reply-To: <1574672497.1222697444456.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/VELOCITY-618?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Byron Foster updated VELOCITY-618: ---------------------------------- Attachment: strictPropertyAndVariable_3.patch Patch 3 contains the changes discusses about the #if statement. Mainly, if a variable is referenced alone within an #if expression then the variable is evaluated as if strict mode is false. So the following examples will work (Won't throw exceptions): #if($bogus) #if($bogus && $bogus.foo) // Short circuit, and bogus has foo #if($val == "junk" || $bogus) // Works if $val is defined #if($bogus1 || $bogus2) The following will throw an exception #if($bogus == "junk") #if($bogus.foo) #if($bogus > 4) So, I have mixed feeling about this solution.. but I think I can live with it. This is a special case, but the special case sort of stands out, and may actually be somewhat intuitive... If someone wants to actually test if a variable exists then they can use #if($foo != $NULL). and I like the ability to do #If($foo && $foo.bar). Unit tests are included. If this looks good I'll submit a patch for docs. > Strict property and method references > ------------------------------------- > > Key: VELOCITY-618 > URL: https://issues.apache.org/jira/browse/VELOCITY-618 > Project: Velocity > Issue Type: Improvement > Components: Engine > Reporter: Byron Foster > Fix For: 1.5.1, 1.6 > > Attachments: strictPropertyAndVariable_2.patch, strictPropertyAndVariable_3.patch > > > The given patch against trunk adds a new option 'runtime.references.strict'. When set to true, invalid property references will throw a InvalidMethodException. For example $foo.bar will throw an exception if the object contained in $foo has no such property as bar. Any kind of reference to bar will cause an exception including: > #if(#foo.bar) > #set($foo.bar = "junk") > #set($foo.getBar()) > etc... -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online. --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org For additional commands, e-mail: dev-help@velocity.apache.org