Velocity
  1. Velocity
  2. VELOCITY-528

Velocity 1.5 raises errors for templates that ran in 1.4.

    Details

    • Type: Improvement Improvement
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.5
    • Fix Version/s: 1.6
    • Component/s: Documentation
    • Labels:
      None
    • Environment:
      Windows XP SP2, JDK 1.5

      Description

      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.

        Activity

          People

          • Assignee:
            Unassigned
            Reporter:
            Michael Giroux
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development