moved template engine to api (FIXME)