1 package org.tigris.scarab.util; 2 3 48 49 import org.apache.turbine.Turbine; 50 import org.apache.turbine.RunData; 51 import org.apache.turbine.modules.Module; 52 import org.apache.commons.logging.Log; 53 import org.apache.commons.logging.LogFactory; 54 55 64 public class SnippetRenderer 65 implements SkipFiltering 66 { 67 private static final Log LOG = LogFactory.getLog(SnippetRenderer.class); 68 private static final String SNIPPETS = "snippets"; 69 72 private RunData data; 73 private String template; 74 75 78 public SnippetRenderer(RunData data, String template) 79 { 80 this.data = data; 81 this.template = template; 82 } 83 84 92 public String toString() 93 { 94 String result = null; 95 LOG.debug("Rendering snippet " + template); 96 try 97 { 98 result = Module.handleRequest( 99 Module.getTemplateContext(data), 100 Turbine.getResolver().getTemplate(SNIPPETS, template)); 101 } 102 catch (Exception e) 103 { 104 LOG.error("Error rendering " + template + ". ", e); 105 result = "ERROR!"; 106 } 107 return result; 108 } 109 } 110 | Popular Tags |