Coverage Report - org.webslinger.macros.SectionMacro
 
Classes in this File Line Coverage Branch Coverage Complexity
SectionMacro
100%
9/9
100%
1/1
0
SectionMacro$1
100%
3/3
N/A
0
 
 1  
 package org.webslinger.macros;
 2  
 
 3  
 import java.io.IOException;
 4  
 import java.io.Writer;
 5  
 import java.util.ListIterator;
 6  
 import java.util.Map;
 7  
 import javax.servlet.ServletException;
 8  
 
 9  
 import org.apache.bsf.BSFException;
 10  
 
 11  
 import org.webslinger.PathContext;
 12  
 import org.webslinger.Webslinger;
 13  
 import org.webslinger.WebslingerInvoker;
 14  
 import org.webslinger.WebslingerInvoker.AlterPlan;
 15  
 import org.webslinger.WebslingerInvoker.Plan;
 16  
 import org.webslinger.template.TemplateMacro;
 17  
 import org.webslinger.template.TemplateManager;
 18  
 
 19  
 public class SectionMacro extends AbstractSimpleMacro {
 20  
     protected SectionMacro(String name, boolean withTemplate, boolean isBlock) {
 21  100
         super(name, withTemplate, isBlock);
 22  100
     }
 23  
 
 24  
     protected boolean render(TemplateManager manager, Webslinger parent, Writer writer, Args args, Map<String, Object> context, Body body) throws IOException, BSFException {
 25  
         //(name, editable, writer) -> mergeTemplate(file, editable, writer)
 26  81
         String name = (String) args.get("name", 0);
 27  
         boolean editable;
 28  81
         Plan plan = parent.getInvoker().getPlan();
 29  81
         PathContext section = plan.findSection(name);
 30  81
         if (section == null) return false;
 31  77
         final PathContext[] templates = getTemplates(parent, args, 1);
 32  77
         plan.merge(plan, section, null, writer, new AlterPlan() {
 33  
             protected void alterPlan(Plan plan) throws IOException, ServletException {
 34  77
                 plan.addTemplates(templates);
 35  77
             }
 36  
         });
 37  77
         return true;
 38  
     }
 39  
 }
 40