Re: Apache Velocity : Verify if all substitutions are made
Debraj Manna <[email protected]> Tue, 13 Jun 2023 17:26:21 +0530
| Newsgroups | gmane.comp.jakarta.velocity.user |
|---|---|
| Message-ID | <CAF6DVKN07Ndd9+U4EAS_3OqdzpcYgMBmiG4hA-6Lv_+=OkbmSg@mail.gmail.com> |
--000000000000a1409d05fe0187ad
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
I am using velocity 1.7
On Tue, Jun 13, 2023 at 3:08=E2=80=AFPM Debraj Manna <subharaj.manna@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 =3D new VelocityEngine();
> velocityEngine.init();
>
> Template t =3D velocityEngine.getTemplate("card.vm");
>
> VelocityContext context =3D new VelocityContext();
> context.put("firstName", "tuk");
> StringWriter writer =3D 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?
>
--000000000000a1409d05fe0187ad--