velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Moshe Sambol <mos...@businesslayers.co.il>
Subject RE: Template from String
Date Thu, 15 May 2003 13:30:52 GMT
Dave,

The reason evaluate(...) isn't always the right solution is that sometimes
you want to load your templates from Strings today, during development /
testing / whatever, but tomorrow you want your product to load templates
from database / jar / etc. without major changes to the code.

Velocity's ability to choose the appropriate Template loader based on
configuration allows code to be written independently of the source of the
templates.

That is, as long as you use Template objects and Loaders.  If I write my
code your way, using the evaluate method, and then later decide I want my
templates to come from elsewhere, I have to rewrite code.

-Moshe

> -----Original Message-----
> From: Dave Newton [mailto:dave@solaraccess.com] 
> Sent: Thursday, May 15, 2003 4:17 PM
> To: Velocity Users List
> Subject: Re: Template from String
> 
> 
> > I have a database of email messages that are to be used as 
> templates with 
> > Velocity. The examples assume templates will be files 
> (template.vm). I will 
> > be getting the templates as java.lang.String objects. Could 
> someone tell me 
> > how to load a template from a String rather than a file?
> 
http://jakarta.apache.org/velocity/developer-guide.html#Using%20Velocity%20I
n%20General%20Applications

Velocity.evaluate(velocontext, writer, logstr, stringTemplate)

works for me.

If there's a reason that all the other solutions didn't use this and
talked about loaders and all that I'd _really_ like to know, because
I've been using this method for awhile and it works fine for me.

Thanks,
Dave



---------------------------------------------------------------------
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