Template:Function

This is a WIP, feedback is appreciated. To retain readability a lot of HTML comments are used, they shouldn't impact the working of the template, but could add to the confusion a bit. Example in the Sandbox.