'use strict'; Handlebars.registerHelper('sanitize', function(html) { // Strip the script tags from the html, and return it as a Handlebars.SafeString html = html.replace(/)<[^<]*)*<\/script>/gi, ''); return new Handlebars.SafeString(html); }); Handlebars.registerHelper('renderTextParam', function(param) { var result, type = 'text', idAtt = ''; var paramType = param.type || param.schema.type || ''; var isArray = paramType.toLowerCase() === 'array' || param.allowMultiple; var defaultValue = isArray && Array.isArray(param.default) ? param.default.join('\n') : param.default; var dataVendorExtensions = Object.keys(param).filter(function(property) { // filter X-data- properties return property.match(/^X-data-/i) !== null; }).reduce(function(result, property) { // remove X- from property name, so it results in html attributes like data-foo='bar' return result += ' ' + property.substring(2, property.length) + '=\'' + param[property] + '\''; }, ''); if (typeof defaultValue === 'undefined') { defaultValue = ''; } if(param.format && param.format === 'password') { type = 'password'; } if(param.valueId) { idAtt = ' id=\'' + param.valueId + '\''; } defaultValue = defaultValue.replace(/'/g,'''); if(isArray) { result = ''; } else { var parameterClass = 'parameter'; if(param.required) { parameterClass += ' required'; } result = ''; } return new Handlebars.SafeString(result); });