1 16 17 18 package org.apache.velocity.tools.generic; 19 20 21 import java.io.StringWriter ; 22 import org.apache.velocity.app.Velocity; 23 import org.apache.velocity.context.Context; 24 25 26 74 75 public class RenderTool 76 { 77 78 81 public RenderTool() 82 {} 83 84 private static final String LOG_TAG = "RenderTool.eval()"; 85 86 96 public String eval(Context ctx, String vtl) throws Exception 97 { 98 StringWriter sw = new StringWriter (); 99 boolean success = Velocity.evaluate(ctx, sw, LOG_TAG, vtl); 100 if (success) 101 { 102 return sw.toString(); 103 } 104 105 return null; 106 } 107 108 121 public String recurse(Context ctx, String vtl) throws Exception 122 { 123 String result = eval(ctx, vtl); 124 if (result.equals(vtl)) 125 { 126 return result; 127 } 128 else 129 { 130 return recurse(ctx, result); 131 } 132 } 133 134 } 135 | Popular Tags |