return out.toString();
}
public void render(String text, Map<String, Object> attributes, Locale locale, Appendable appendable) throws IOException, TemplateExecutionException, TemplateException {
GroovyTemplateStub template = template(text);
TemplateRenderContext renderContext = new TemplateRenderContext(template, null, attributes, locale);
OutputStream adapter = OutputStream.create(Tools.UTF_8, appendable);
renderContext.render(adapter);
final AtomicReference<IOException> ios = new AtomicReference<IOException>();
adapter.close(new Thread.UncaughtExceptionHandler() {
public void uncaughtException(Thread t, Throwable e) {
if (e instanceof IOException) {
ios.set((IOException)e);