Apache Velocity : Verify if all substitutions are made
Debraj Manna <[email protected]> Tue, 13 Jun 2023 15:08:35 +0530
| Newsgroups | gmane.comp.jakarta.velocity.user |
|---|---|
| Message-ID | <CAF6DVKPiVZ-vcESemzRRUbeJMGOOtV9m61G8b_=0zN48Zszm7Q@mail.gmail.com> |
--000000000000f0250405fdff9abf
Content-Type: text/plain; charset="UTF-8"
Can someone let me know how I can verify a velocity context against a
template? Basically, I want to throw some error if all variables are not
substituted in the velocity template.
For example, let's say I have a velocity template, card.vm
card {
type: CREDIT
company: VISA
name: "${firstName} ${lastName}"
}
The substitution is done like below
VelocityEngine velocityEngine = new VelocityEngine();
velocityEngine.init();
Template t = velocityEngine.getTemplate("card.vm");
VelocityContext context = new VelocityContext();
context.put("firstName", "tuk");
StringWriter writer = new StringWriter();
t.merge( context, writer );
In this case, I want to throw some error specifying that lastName is not
replaced in template.
Does velocity provide anything for this?
--000000000000f0250405fdff9abf--