more generalizations to templates, adds `layout` option to allow a custom layout to be specified for generated HTML