Template updates to interface with JS functions

Updates to the template so that it works with the javascript functions.

Think I have almost finished the reconstruction of the template after
previous loss