Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
let description;
if (typeof format !== 'string') {
format = 'simple';
} else if (!['extended', 'simple'].includes(format)) {
throw new Exception('The {{describeType}} helper accepts the options "simple" ' +
'and "extended".');
} else if (format === 'extended' && typeof property !== 'string') {
property = 'description';
}
if (typeof parsedType === 'object') {
description = catharsis.describe(parsedType, catharsisOptions);
} else {
// We don't know the type
description = catharsis.describe(catharsis.parse('?'), catharsisOptions);
}
if (format === 'extended') {
return new SafeString(_.get(description.extended, property));
} else {
return new SafeString(description.simple);
}
},
Helpers.prototype.describeType = function describeType(parsedType, options) {
var catharsisOptions = {
// TODO: add codeTag and/or codeClass based on config
// TODO: use the correct locale
links: templateHelper.longnameToUrl
};
var description;
options = _.defaults(options || {}, {
format: 'simple'
});
description = catharsis.describe(parsedType, catharsisOptions);
switch(options.format) {
case 'extended':
return description.extended;
default: {
return description.simple;
}
}
};
describeType(parsedType, format, property) {
const catharsisOptions = getCatharsisOptions(template);
let description;
if (typeof format !== 'string') {
format = 'simple';
} else if (!['extended', 'simple'].includes(format)) {
throw new Exception('The {{describeType}} helper accepts the options "simple" ' +
'and "extended".');
} else if (format === 'extended' && typeof property !== 'string') {
property = 'description';
}
if (typeof parsedType === 'object') {
description = catharsis.describe(parsedType, catharsisOptions);
} else {
// We don't know the type
description = catharsis.describe(catharsis.parse('?'), catharsisOptions);
}
if (format === 'extended') {
return new SafeString(_.get(description.extended, property));
} else {
return new SafeString(description.simple);
}
},