[ 
https://issues.apache.org/jira/browse/VELOCITY-528?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Nathan Bubna updated VELOCITY-528:
----------------------------------

      Component/s: Documentation
    Fix Version/s: 1.6
                   1.5.1
       Issue Type: Improvement  (was: Bug)

This bug was raised as a result of this discussion:
http://mail-archives.apache.org/mod_mbox/velocity-user/200703.mbox/[EMAIL 
PROTECTED]

Essentially, the parser was previously gracious to Michael's templates where it 
probably should not have been (though that could be debated).  Now that new 
lines are allowed in method calls, e.g.:

$tool.method( $foo,
                           'bar',
                           "$woogie" )

Michael's templates are breaking in places where he did things like the above, 
but did not mean for such a method to be called, rather he only meant to have 
$tool.method resolve into the name of a java method.

The workaround for this is to update the templates to use formal reference 
notation as so:

${tool.method}( $foo,
                             'bar',
                             "$woogie" )

This was an unintended break in backwards compatibility, due to the fact that 
what Michael was doing previously was never really intended.   Regardless, this 
needs to be added to the release notes, so it does not surprise other users.   
It would also be prudent to make a point in the documentation to recommend 
users always use formal reference notation whenever their reference is followed 
by ANY character other than whitespace.  This makes things clear to both the 
parser and anyone else looking at their template, and thus should be considered 
a best practice.

> Velocity 1.5 raises errors for templates that ran in 1.4.
> ---------------------------------------------------------
>
>                 Key: VELOCITY-528
>                 URL: https://issues.apache.org/jira/browse/VELOCITY-528
>             Project: Velocity
>          Issue Type: Improvement
>          Components: Documentation
>    Affects Versions: 1.5
>         Environment: Windows XP SP2, JDK 1.5
>            Reporter: Michael Giroux
>             Fix For: 1.5.1, 1.6
>
>
> Migrated from Velocity 1.4 to 1.5.  I have several templates that ran in 1.4 
> and now fail in 1.5.  I raised this in the mailing list and Nathan Bubna 
> asked me to file a bug.
> This is probably an error in my template, but 1.4 allowed it to execute 
> without complaints.  I might have been lucky that nothing bad happened.  
> Existing templates contain the following.
>  public $method.returnType $method.name(
>  #foreach($param in $parameters)
>     ...
>  #end
> The intent here is to emit a java method signature for a method named 
> $method.name .  This works in 1.4.
> In Velocity 1.5, an error is thrown indicating that the #foreach is 
> unexpected.  Velocity 1.5 is expecting a method parameter becuase the 
> variable name is terminated by an open paren.
> I fixed the problem by adding curly braces to the template as follows:
>  public $method.returnType ${method.name}(
>  #foreach($param in $parameters)
>     ...
>  #end
> This is probably a bug in 1.4, and poor coding practice in my template, but 
> given the fact that it did work and now doesn't, there should be some mention 
> of this "improvement" in the 1.5 release notes.

-- 
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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to