Uploaded image for project: 'Velocity'
  1. Velocity
  2. VELOCITY-792

Template if statement throws off tabbing

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.0
    • Fix Version/s: 2.0
    • Component/s: None
    • Labels:
      None
    • Environment:
      Eclipse IDE.
      Microsoft XP.

      Description

      When using a velocity template for XML output. I encounter tabbing issues when using an IF statement. Below you can find an example of what is happening:

      Template which produces erroneous tabbing:

      #foreach($order in $orderList)
      <type>
      #if("$order.type" == "AZ")
      <AZ>
      <fiveYears>$order.typeVar1</fiveYears>
      <thirtyNineMonths>$order.typeVar2</thirtyNineMonths>
      </AZ>
      #end
      </type>
      #end

      Output of erroneous tabbing:
      <type>
      <AZ>
      <fiveYears>true</fiveYears>
      <thirtyNineMonths>false</thirtyNineMonths>
      </AZ>
      </type>

      If I remove the indentation from the #if and #end then the output is normal. Having to remove the indentation is undesirable as it makes the template difficult to read.

      Template with removed indentation for #if and #end:

      #foreach($order in $orderList)
      <type>
      #if("$order.type" == "AZ")
      <AZ>
      <fiveYears>$order.typeVar1</fiveYears>
      <thirtyNineMonths>$order.typeVar2</thirtyNineMonths>
      </AZ>
      #end
      </type>
      #end

      Output with indentation for #if and #end removed;
      <type>
      <AZ>
      <fiveYears>true</fiveYears>
      <thirtyNineMonths>false</thirtyNineMonths>
      </AZ>
      </type>

        Attachments

          Activity

            People

            • Assignee:
              cbrisson Claude Brisson
              Reporter:
              kswanso Kevin Swanson
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: