underscore-template-loader
Version:
An Underscore and Lodash template loader for Webpack
17 lines (15 loc) • 379 B
JavaScript
// Transforms a value to an expected text
function toText (value) {
if (value instanceof Array) {
return value.map(toText).join(',');
} else if (value instanceof Object) {
var str = '';
for (var k in value) {
str += ('<' + k + '>' + toText(value[k]) + '</' + k + '>');
}
return str;
} else {
return value + '';
}
}
module.exports = toText;