RE: template-encoding

"Anthony Eden" <[email protected]> Sat, 21 Dec 2002 13:26:26 -0500
Newsgroups gmane.comp.java.jpublish.devel
Message-ID <000001c2a91e$79c657f0$01000001@mobile1>
Thanks for the patch, I have checked it in.

Sincerely,
Anthony Eden

> -----Original Message-----
> From: [email protected] 
> [mailto:[email protected]] On 
> Behalf Of Alexander Povargo
> Sent: Wednesday, December 18, 2002 4:20 PM
> To: [email protected]
> Subject: [JPublish-developer] template-encoding
> 
> 
> Hello,
> 
> After Velocity.evaluate(...) was moved from 
> JPublishServlet.java to Template.java, template-encoding 
> isn't working.
> 
> Here correction of Template.java:
> ----------
> // add this to import section:
> import java.io.UnsupportedEncodingException;
> import org.jpublish.util.CharacterEncodingMap;
> 
> // ...
> 
> public void merge(JPublishContext context, Page page, Writer out) 
> 	throws TemplateMergeException{
> 	try{
> 		CharacterEncodingMap characterEncodingMap = 
> 	
> (CharacterEncodingMap)context.get("characterEncodingMap");
> 		String templateEncoding =
> 		 	characterEncodingMap.getTemplateEncoding();
> 		Velocity.evaluate(context, out, page.getPath(),  
> 			getReader(templateEncoding));
> 		log.debug("Merge complete.");
> 	} catch(Exception e){
> 		throw new TemplateMergeException(e.getMessage(), e);
> 	}
> }
> 
> protected Reader getReader(String templateEncoding){
> 	String result = "";
> 	try {
> 		result = new String(templateText.getBytes(), 
> templateEncoding);
> 	} catch (UnsupportedEncodingException e) {
> 		result = templateText;
> 	}
> 	return new StringReader(result);
> }
> ----------
> 
> After this changes template-encoding is working now.
> 
> Regards,
> Alexander Povargo
> [email protected]
> 
> 
> 
> 
> -------------------------------------------------------
> This SF.NET email is sponsored by: Order your Holiday Geek 
> Presents Now! Green Lasers, Hip Geek T-Shirts, Remote Control 
> Tanks, Caffeinated Soap, MP3 Players,  XBox Games,  Flying 
> Saucers,  WebCams,  Smart Putty.
> T H I N K G E E K . C O M       http://www.thinkgeek.com/sf/
> _______________________________________________
> Jpublish-developer mailing list 
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/jpublish-developer
> 



-------------------------------------------------------
This SF.NET email is sponsored by: Order your Holiday Geek Presents Now!
Green Lasers, Hip Geek T-Shirts, Remote Control Tanks, Caffeinated Soap,
MP3 Players,  XBox Games,  Flying Saucers,  WebCams,  Smart Putty.
T H I N K G E E K . C O M       http://www.thinkgeek.com/sf/