Coverage Report - org.webslinger.ext.template.freemarker.LocalFreemarkerTemplate
 
Classes in this File Line Coverage Branch Coverage Complexity
LocalFreemarkerTemplate
100%
10/10
100%
2/2
0
 
 1  
 package org.webslinger.ext.template.freemarker;
 2  
 
 3  
 import java.io.IOException;
 4  
 import java.io.Reader;
 5  
 import java.io.Writer;
 6  
 import java.util.HashMap;
 7  
 import java.util.Map;
 8  
 
 9  
 import freemarker.template.Configuration;
 10  
 import freemarker.template.Template;
 11  
 import freemarker.template.TemplateException;
 12  
 
 13  
 public class LocalFreemarkerTemplate extends Template {
 14  
     private final String[] names;
 15  
 
 16  
     public LocalFreemarkerTemplate(String path, Reader reader, Configuration config, String encoding, String[] names) throws IOException {
 17  3
         super(path, reader, config, encoding);
 18  3
         this.names = names;
 19  3
     }
 20  
 
 21  
     public void process(Map<String, ? extends Object> macros, Object[] args) throws IOException, TemplateException {
 22  3
         Map<String, Object> context = new HashMap<String, Object>();
 23  3
         if (args[1] != null) context.putAll((Map<String, ? extends Object>) args[1]);
 24  3
         context.putAll(macros);
 25  12
         for (int i = 2; i < names.length; i++) {
 26  9
             context.put(names[i], args[i]);
 27  
         }
 28  3
         super.process(context, (Writer) args[0]);
 29  3
     }
 30  
 }