Class StringTemplateLoader

Vaibhav <[email protected]> Thu, 12 Mar 2015 16:09:10 +0530
Newsgroups gmane.comp.web.freemarker.devel
Message-ID <[email protected]>
Hello devs,

This is with reference to class freemarker.cache.StringTemplateLoader

I have a requirement where I want to create templates on the fly from 
strings.
The templates will be stored in String fromat in database.

For this I am first loading the custom template in TemplateLoader and 
then retreiving it by passing the datamodel map.

Below is the sample code for this.

After I am done, I want to remove the loaded template from the 
TemplateLoader.

I tried extending the StringTemplateLoader class for this purpose but 
there is no getter method specified for the template map in this class.

Maybe we can add a remove method to this class.
If the remove method has not been deliberately added, can you please 
enlighten me on this.

/public//String freemarkerDo(Map datamodel, CustomEmailTemplate cet){//
//    StringBuffer content =//new//StringBuffer();//
//    StringBuilder sb =//new//StringBuilder();//
//    sb.append(cet.getEmailTemplateType().getName()).append(cet.getCommunity().getId());//
//    //if//(CommonUtil.//isNotNull//(cet)){//
//       StringTemplateLoader loader = (StringTemplateLoader)//cfg//.getConfiguration().getTemplateLoader();//
//       String templateSource = cet.getEmailContent().getEmailContent();//
//       loader.putTemplate(sb.toString(), templateSource);//
//       //cfg//.getConfiguration().setTemplateLoader(loader);//
//       //try//{//
//          Template tpl =//cfg//.getConfiguration().getTemplate(sb.toString());//
//          content.append(FreeMarkerTemplateUtils.//processTemplateIntoString//(tpl, datamodel));//
//       }//catch//(Exception e) {//
//          //log//.error(//"Error retreiving custom template for community:{} of type {}"//,cet.getCommunity().getId(),cet.getEmailTemplateType().getName());//
//       }//
//       //return//content.toString();//
//    }//
//    //return null//;//
//}/


Thanks
Vaibhav

------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the 
conversation now. http://goparallel.sourceforge.net/

_______________________________________________
FreeMarker-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freemarker-devel