I think what you want to do is to assign a variable inside template.js. Then you have the variable available for use wherever you want in jquery. Something like:
var tpl = " ...
"
Wouldn't this be a simpler solution to your problem? We do this in Ext JS. I think this will work for you in jQuery.