velocity-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Byron Foster (JIRA)" <>
Subject [jira] Updated: (VELOCITY-618) Strict property and method references
Date Mon, 06 Oct 2008 02:55:44 GMT


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 && $  // 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 > 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 && $

Unit tests are included.

If this looks good I'll submit a patch for docs.

> Strict property and method references
> -------------------------------------
>                 Key: VELOCITY-618
>                 URL:
>             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 $
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(
> #set($ = "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:
For additional commands, e-mail:

View raw message