public String getType() { if (directive != null) { switch (directive.getType()) { case Directive.BLOCK: return "block"; case Directive.LINE: return "line"; } } if (template != null) { return template.getEncoding(); } return null; }
public String getType() { if (directive != null) { switch (directive.getType()) { case Directive.BLOCK: return "block"; case Directive.LINE: return "line"; } } if (template != null) { return template.getEncoding(); } return null; }
private void render(final Template template, final Map<String, Object> dataModel, final HttpServletResponse response) throws IOException { // ATM all templates render HTML response.setContentType("text/html"); final OutputStream outputStream = response.getOutputStream(); final Context context = new VelocityContext(dataModel); try { final Writer tmplWriter; // Load the template if (template.getEncoding() == null) { tmplWriter = new BufferedWriter(new OutputStreamWriter(outputStream)); } else { tmplWriter = new BufferedWriter(new OutputStreamWriter(outputStream, template.getEncoding())); } // Process the template template.merge(context, tmplWriter); tmplWriter.flush(); } catch (IOException e) { // NEXUS-3442 // IOEx should be propagated as is throw e; } catch (Exception e) { // All other (Velocity exceptions are RuntimeExcptions!) to be wrapped, but preserve cause too throw new IOException("Template processing error: " + e.getMessage(), e); } }
final Writer tmplWriter; if (template.getEncoding() == null) { tmplWriter = new BufferedWriter(new OutputStreamWriter(outputStream)); tmplWriter = new BufferedWriter(new OutputStreamWriter(outputStream, template.getEncoding()));
outputStream, getCharacterSet().getName())); } else { if (getTemplate().getEncoding() == null) { tmplWriter = new BufferedWriter(new OutputStreamWriter( outputStream)); } else { tmplWriter = new BufferedWriter(new OutputStreamWriter( outputStream, getTemplate().getEncoding()));
reader = resourceLoader.getResourceReader(name, getEncoding());