Introduce JS templates

Let me know if you have any questions / remarks about the code. Each commit contain a different set of changes.