Factor out template expansion code

create common code for template contexts with BuildConfig and Release info
create common routines for expanding a single file, and a whole tree
for the tree expansion case, support a top level directory of sub-templates that isn't copied over