Added support for nexted templates