JsRender lets you register templates from strings, as well as from script blocks.
See http://www.jsviews.com/#compiletmpl.
So instead of writing:
var mainTemplate = $.templates("#main-menu-form-tmpl");
and then calling mainTemplate.render(...)
or mainTemplate.link(...)
etc. you can instead remove your template script block and instead pass your template markup as a string to $.templates()
as in:
var mainTemplate = $.templates("... {{if (index && (index == 0 || ...");
...
Or if you want you can keep the script block declaration, but with escaped ampersands and then get the contents of the script block as a string, unescape the ampersands, and pass that string to your template definition:
var mainTemplateString = $("#main-menu-form-tmpl").text().replace(/&/g, "&");
var mainTemplate = $.templates(mainTemplateString);
...
Alternatively you can wrap your template block in <![CDATA
and again, strip the wrapper to get the real template markup string you want to pass to the template definition:
var mainTemplateString = $("#main-menu-form-tmpl").text().slice(16, -10);
var mainTemplate = $.templates(mainTemplateString);
...