Enabled with-statement in templates.

In the process refactored almost all of the source. I'm so funny.
Added sorting filter for containers of dictionaries.
Added argparse, to parse args.

Introduces the --try-keys option: If a template variable resolves to a dictionary, try to output the value of the first try-key that matches.
Delegated the creation of the finalize function to the __main__ block.