This patch adds and improves docstrings in templates.py. Change-Id: I11a8a803f19597cdee7f475b98e1ef9648604c3e