I am using velocity 1.7

On Tue, Jun 13, 2023 at 3:08 PM Debraj Manna <subharaj.ma...@gmail.com>
wrote:

> 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?
>

Reply via email to