Since this is used in many templates, we cannot assume it's js_wright template.  Please load the template in a variable using by getting the getTemplate function (it's an static function in one of the Joomla classes, you can see examples in other parts of the Wright code)