Major rewrite for modularity/extensibility/name change.

Supports per-document templates (Closes #5)

--HG--
extra : amend_source : ab09df3b19608101cba5beaf98810ca65e65e1ba