added support for nested templating