public void render(final String template, final Handler<Object> next) {
int sep = template.lastIndexOf('.');
if (sep != -1) {
String extension = template.substring(sep);
final Engine renderEngine = engines.get(extension);
if (renderEngine == null) {
next.handle("No engine registered for extension: " + extension);
} else {
renderEngine.render(template, context, new AsyncResultHandler<Buffer>() {
@Override
public void handle(AsyncResult<Buffer> asyncResult) {
if (asyncResult.failed()) {
next.handle(asyncResult.cause());
} else {
setContentType(renderEngine.contentType(), renderEngine.contentEncoding());
end(asyncResult.result());
}
}
});
}