Make period elements templates

Added a very basic "template" system for the period elements. Also, fixed bug where a <span> was not properly closed in the compact template.