wms-xmlify-copy-resource
Version:
Convert a JSON-encoded WMS Copy Resource object into its XML equivalent
24 lines (19 loc) • 507 B
JavaScript
module.exports = function elementFactory (tag, attr, children) {
var openTag = tag
if (!empty(attr)) {
for (var a in attr) {
openTag += ' '+a+'="'+attr[a]+'"'
}
}
if (children === null || children === undefined || children.length === 0)
return '<'+openTag+' />'
return '<'+openTag+'>'+(Array.isArray(children) ? children.join('') : children)+'</'+tag+'>'
}
function empty (o) {
for (var k in o) {
if (o.hasOwnProperty(k)) {
return false
}
}
return true
}