Add templates to head script blocks rather than into dom.