added option to provide custom template.
todo: add documentation on how to write a template