public Template createTemplate(Reader reader) throws CompilationFailedException, IOException {
SimpleTemplate template = new SimpleTemplate();
String script = template.parse(reader);
if (verbose) {
System.out.println("\n-- script source --");
System.out.print(script);
System.out.println("\n-- script end --\n");
}
try {
template.script = groovyShell.parse(script, "SimpleTemplateScript" + counter++ + ".groovy");
} catch (Exception e) {
throw new GroovyRuntimeException("Failed to parse template script (your template may contain an error or be trying to use expressions not currently supported): " + e.getMessage());
}
return template;
}
|