velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nathan Bubna" <nbu...@gmail.com>
Subject Re: Escaping double quote characters during variable substitution?
Date Mon, 24 Apr 2006 17:16:45 GMT
The solution upcoming in Velocity 1.5 is definitely the best.  But for
now, VelocityTools 1.2 (which has been released) contains an
EscapeTool.  The syntax isn't ideal, but it isn't as messy as your
example :)

$esc.html($myBean.name)

http://jakarta.apache.org/velocity/tools/generic/EscapeTool.html#html()

On 4/24/06, Joe Desbonnet <jdesbonnet@gmail.com> wrote:
> I've forms with velocity lines like this:
>
> <input type="text" name="myparam" value="$myBean.getName()" />
>
> Occasionally myParamValue will contain a double quote character which
> causes HTML parsing problems. I could of course define some object
> with a filter method and include it in the velocity context ... eg:
>
> <input type="text" name="myparam"
> value="$filterObject.escapeQuotes($myBean.getName())" />
>
> but this is rather messy.
>
> Is there a way to put all variable substitutions through a filter? Or
> any other elegant solutions?
>
> Thanks,
> Joe.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org


Mime
View raw message