velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nathan Bubna" <nbu...@gmail.com>
Subject Re: A question about using macros
Date Mon, 18 Jun 2007 17:07:33 GMT
On 6/18/07, apache@recks.org <apache@recks.org> wrote:
> Hi Serge,
>
> the escaping of the characters #$'" does not work in all cases.
> I suggest you try:
>
> #set( $H = '#' )
> #set( $D = '$' )
> #set( $Q = '"' )
> #set( $S = "'" )
>
> #mymacro( $attribute "${H}include ${Q}${attribute.type.name}.h${Q}")
>
> You could also use the EscapeTool (from the VelocityTools subproject).

all of the above are true.

> Alternatively, since Velocity 1.5 you can escape quotes by doubling
> them.

sadly, this is not.  we had consensus supporting this decision, and
Geir had working code for it.   but somehow it never made it in.  i
asked Geir about it a few months back, and he was going to try and
find the code but i don't think he has.  or if he did find it, i
haven't heard about it.  i'm going to open a jira issue on this, so we
have a place to point to about this and remind us.

>
> Cheers,
> Christoph
>
> Serge Emantayev wrote:
> > Hi everyone,
> > I just started to use the Velocity templates. It's an amazing tool. I've a problem
using velocity macros. I have following:
> >
> > #macro (mymacro $arg $action)
> > #if (some condition on $arg)
> > $action
> > #end
> > #end
> >
> > Now, I want to call my macro following way (yes, it's c++ code generation :-) ):
> >
> > #mymacro ($attribute "\#include \"${attribute.type.name}.h\"")
> >
> > The purpose is to put #include "type.h" whenever the attribute matches a criterion.
Unfortunately, this code does not work, it breaks somewhere near "\#include...". Can you help
me to fix it?
> >
> > Thank you,
> > Serge Emantayev
> > mailto:sergeem@yahoo.com
> >
> >
> >
> >
> >
> > ____________________________________________________________________________________
> > Pinpoint customers who are looking for what you sell.
> > http://searchmarketing.yahoo.com/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> For additional commands, e-mail: user-help@velocity.apache.org
>
>

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


Mime
View raw message