You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by "Ford, Peter" <Pe...@travelocity.com> on 2004/05/20 21:15:25 UTC

How to get unprocessed template from VelocityEngine?

I'm probably missing something obvious here, but what I need to do is pull the raw VTL source for a template from the VE by name so that it can be displayed without any processing. I tried:

String vtl = velocityEngine.getTemplate("ConfirmationMail").getData();

It won't compile because getData() returns an Object but that's beside the point because the way I understand it, the data it returns is not actually the template anyway.

It looks like I may have to something like this:

String tpl = "ConfirmationMail";
InputStream is = velocityEngine.getTemplate(tpl).getResourceLoader().getResourceStream(tpl);

... then mess about to read from "is" into a StringBuffer or somthing. Is there an easier way?

--Pete

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


Re: How to get unprocessed template from VelocityEngine?

Posted by Barbara Baughman <ba...@utdallas.edu>.
How about creating a template display.vm that looks like
#include($template)

where $template is the name of the velocity template you want to
display.  The include directive does not parse, so you don't have to
do anything fancy to get that output.

Barbara Baughman
X2157


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