You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Katrin Möller <ka...@gmail.com> on 2005/06/01 09:14:23 UTC
Re: parse custom markers
Hi,
nope,
context.put("KEY$","value");
isn't working (it's not identifying the whole key):
and I can't swap to
sometext $KEY sometext
because of other requirements of the project.
On 5/31/05, Shinobu Kawai <sh...@gmail.com> wrote:
> Hi Katrin,
>
> > I'm trying to parse a given template containing custom markers.
> > Sample template:
> > "sometext $KEY$ sometext"
> > The easyiest way would be to parse it with a VelocityContext
> > containing KEY as a marker:
> > context.put("KEY","value");
> > The parsed String is then "sometext value$ sometext".
> > This is nasty because first, the remaining "$" must be replaced
> > manually and second, even an incomplete marker ($KEY) would be parsed.
> >
> > How can I find a smarter workaround for this?
>
> What's stopping you from just doing this?
> sometext $KEY sometext
>
> Best regards,
> -- Shinobu
>
> --
> Shinobu Kawai <sh...@gmail.com>
>
> ---------------------------------------------------------------------
> 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
Re: parse custom markers
Posted by Katrin Möller <ka...@gmail.com>.
Hi Shinobu,
thanks for your advice! I don't know by now which way I will choose
but your suggestions sound good.
Best regards,
Katrin
On 6/3/05, Shinobu Kawai <sh...@gmail.com> wrote:
> Hi Katrin,
>
> > nope,
> > context.put("KEY$","value");
> > isn't working (it's not identifying the whole key):
> >
> > and I can't swap to
> > sometext $KEY sometext
> > because of other requirements of the project.
>
> I can think of two solutions.
>
> 1. Don't use Velocity.
> Looks like you're not dealing with a Velocity template. You might be
> better off using other technologies, such as regular expressions.
> http://jakarta.apache.org/oro/index.html
> http://java.sun.com/j2se/1.5.0/docs/api/java/util/regex/package-summary.html
>
> 2. Hack Velocity.
> You'll have to change the parser behaviour to achieve what you want.
> Take a look at this article for some starter information:
> http://wiki.apache.org/jakarta-velocity/HackingVelocity
>
> Best regards,
> -- Shinobu
>
> --
> Shinobu Kawai <sh...@gmail.com>
>
> ---------------------------------------------------------------------
> 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
Re: parse custom markers
Posted by Shinobu Kawai <sh...@gmail.com>.
Hi Katrin,
> nope,
> context.put("KEY$","value");
> isn't working (it's not identifying the whole key):
>
> and I can't swap to
> sometext $KEY sometext
> because of other requirements of the project.
I can think of two solutions.
1. Don't use Velocity.
Looks like you're not dealing with a Velocity template. You might be
better off using other technologies, such as regular expressions.
http://jakarta.apache.org/oro/index.html
http://java.sun.com/j2se/1.5.0/docs/api/java/util/regex/package-summary.html
2. Hack Velocity.
You'll have to change the parser behaviour to achieve what you want.
Take a look at this article for some starter information:
http://wiki.apache.org/jakarta-velocity/HackingVelocity
Best regards,
-- Shinobu
--
Shinobu Kawai <sh...@gmail.com>
---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org