lib: support custom templates