You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by sunil goyal <go...@yahoo.com> on 2005/01/28 20:39:23 UTC
getting template from string
Hello all,
I am using Velocity within some
servlets(VelocityServlet). I want to get a template
from a String rather than a file. I am not able to
find the appropriate function for that.
For getting a template from file, there is a method
called
Template getTemplate(String path) in VelocityServlet.
I am storing small template files as String in a
database, and want to construct template from that
string.
Template getTemplateFromString(String data) or an
InputStream ?
Thanks
Regards
Sunil
__________________________________
Do you Yahoo!?
Yahoo! Mail - You care about security. So do we.
http://promotions.yahoo.com/new_mail
---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org
Re: getting template from string
Posted by Claude Brisson <cl...@renegat.net>.
Hi.
On Fri, 2005-01-28 at 11:39 -0800, sunil goyal wrote:
> Hello all,
>
> I am using Velocity within some
> servlets(VelocityServlet).
VelocityServlet is deprecated. You should use VelocityViewServlet, from
the tools subproject.
> I want to get a template
> from a String rather than a file. I am not able to
> find the appropriate function for that.
>
> For getting a template from file, there is a method
> called
> Template getTemplate(String path) in VelocityServlet.
>
> I am storing small template files as String in a
> database, and want to construct template from that
> string.
>
> Template getTemplateFromString(String data) or an
> InputStream ?
You can check the VelocityEngine.evaluate method
http://jakarta.apache.org/velocity/api/org/apache/velocity/app/VelocityEngine.html
--
Claude
--
---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org
Re: getting template from string
Posted by Nathan Bubna <nb...@gmail.com>.
if you just want to evaluate strings, use the "evaluate()" method of
Velocity or VelocityEngine. If you actually want Template objects,
that's a little trickier. However, I do remember seeing a
StringResourceLoader being contributed sometime back for this purpose,
but i'm not sure it ever made it into cvs or the wiki. you should try
searching the velocity-dev list archives for "StringResourceLoader".
On Fri, 28 Jan 2005 11:39:23 -0800 (PST), sunil goyal
<go...@yahoo.com> wrote:
> Hello all,
>
> I am using Velocity within some
> servlets(VelocityServlet). I want to get a template
> from a String rather than a file. I am not able to
> find the appropriate function for that.
>
> For getting a template from file, there is a method
> called
> Template getTemplate(String path) in VelocityServlet.
>
> I am storing small template files as String in a
> database, and want to construct template from that
> string.
>
> Template getTemplateFromString(String data) or an
> InputStream ?
>
> Thanks
>
> Regards
> Sunil
>
> __________________________________
> Do you Yahoo!?
> Yahoo! Mail - You care about security. So do we.
> http://promotions.yahoo.com/new_mail
>
> ---------------------------------------------------------------------
> 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