3

What is the difference between the following two declarations and how does is work?

name="$!{fieldName}" and name="$fieldName"

1
  • code formatting; fixed spelling and title
    – KittMedia
    May 9, 2016 at 7:06

1 Answer 1

3

Quiet Reference Notation:

When Velocity encounters an undefined reference, its normal behavior is to output the image of the reference. For example, suppose the following reference appears as part of a VTL template.

<input type="text" name="email" value="$email"/>

When the form initially loads, the variable reference $email has no value, but you prefer a blank text field to one with a value of "$email". Using the quiet reference notation circumvents Velocity's normal behavior; instead of using $email in the VTL you would use $!email. So the above example would look like the following:

<input type="text" name="email" value="$!email"/>

Now when the form is initially loaded and $email still has no value, an empty string will be output instead of "$email".

Source: https://velocity.apache.org/engine/releases/velocity-1.5/user-guide.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.