1 package org.apache.turbine.pipeline; 2 3 56 57 import org.apache.turbine.Turbine; 58 import org.apache.turbine.RunData; 59 import org.apache.turbine.modules.Module; 60 import org.apache.turbine.TurbineException; 61 import org.apache.turbine.TemplateContext; 62 import org.apache.commons.logging.Log; 63 import org.apache.commons.logging.LogFactory; 64 65 80 public class Renderer 81 { 82 private static final Log log = LogFactory.getLog(Renderer.class); 83 84 87 protected RunData data = null; 88 89 92 public Renderer(RunData data) 93 { 94 this.data = data; 95 } 96 97 105 public String render(String template) 106 throws TurbineException, Exception 107 { 108 log.debug("Rendering template " + template); 109 110 TemplateContext context = Module.getTemplateContext(data); 111 112 return Module.handleRequest( context, template ); 113 } 114 115 118 public String render(String type, String target) 119 throws TurbineException, Exception 120 { 121 String template = Turbine.getResolver().getTemplate(type, target); 122 123 return render( template ); 124 } 125 126 130 public String render(String type, String target, String defaultTarget) 131 throws TurbineException, Exception 132 { 133 String template = Turbine.getResolver().getTemplate(type, target); 134 135 if (Module.templateExists(template)) 136 { 137 return render(template); 138 } 139 else 140 { 141 return render(type, defaultTarget); 142 } 143 } 144 } 145 | Popular Tags |