Add support for defining templates in config

Support passing an object in templates.set.

Fix #406