Add functionality to collect all parameters that are reference values

This will make it easy for users to pull out all reference names they
would need to compile the template.

Also, fix a bug where collectTemplates() doesn't explore the 'else' of a
block.