tags:

views:

33

answers:

1

I use velocity to merge a String(template) with field like

hi there I'am ${name},
And I'am ${age} old.

velocity merged the field ${name} and ${age} with a kind of hashtable:

velocityEngine.evaluate(context, writer, "", template);

context is the hashtable(or better a VelocityContext type)

I want when Velocity can't find the field in the context he just delete them.

can i do this with a property or something?

+1  A: 

Not sure if it is what you are asking, but if you want to prevent unassigned template vars from showing up in merged templates, you can use quiet notation by writing $!{name}, there is also a global setting for that.

serg
This is exactly what i needed! great. thx
michel