Partial support for templates. Var substition not working properly yet.