protected String genHTML ( final HttpServletRequest request , final Map < String , Object > dataModel , final Template template ) throws Exception { final StringWriter stringWriter = new StringWriter ( ) ; template . setOutputEncoding ( "UTF-8" ) ; template . process ( dataModel , stringWriter ) ; final StringBuilder pageContentBuilder = new StringBuilder ( stringWriter . toString ( ) ) ; final long endimeMillis = System . currentTimeMillis ( ) ; final String dateString = DateFormatUtils . format ( endimeMillis , "yyyy/MM/dd HH:mm:ss" ) ; final long startTimeMillis = ( Long ) request . getAttribute ( Keys . HttpRequest . START_TIME_MILLIS ) ; final String msg = String . format ( "\n<!-- Generated by Latke (https://github.com/b3log/latke) in %1$dms, %2$s -->" , endimeMillis - startTimeMillis , dateString ) ; pageContentBuilder . append ( msg ) ; return pageContentBuilder . toString ( ) ; }
Processes the specified FreeMarker template with the specified request data model .