mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
let CSV obj->css allow blank columns in template
This commit is contained in:
parent
217c9718e4
commit
6ae1a5ba0d
@ -69,9 +69,15 @@ module.exports = function(RED) {
|
|||||||
ou += msg.payload[s].join(node.sep) + node.ret;
|
ou += msg.payload[s].join(node.sep) + node.ret;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (node.template[0] !== '') {
|
if ((node.template.length === 1) && (node.template[0] === '')) {
|
||||||
|
node.warn(RED._("csv.errors.obj_csv"));
|
||||||
|
}
|
||||||
|
else {
|
||||||
for (var t=0; t < node.template.length; t++) {
|
for (var t=0; t < node.template.length; t++) {
|
||||||
|
if (node.template[t] === '') {
|
||||||
|
ou += node.sep;
|
||||||
|
}
|
||||||
|
else {
|
||||||
// aaargh - resorting to eval here - but fairly contained front and back.
|
// aaargh - resorting to eval here - but fairly contained front and back.
|
||||||
var p = RED.util.ensureString(eval("msg.payload[s]."+node.template[t]));
|
var p = RED.util.ensureString(eval("msg.payload[s]."+node.template[t]));
|
||||||
|
|
||||||
@ -85,9 +91,9 @@ module.exports = function(RED) {
|
|||||||
}
|
}
|
||||||
else { ou += p + node.sep; } // otherwise just add
|
else { ou += p + node.sep; } // otherwise just add
|
||||||
}
|
}
|
||||||
|
}
|
||||||
ou = ou.slice(0,-1) + node.ret; // remove final "comma" and add "newline"
|
ou = ou.slice(0,-1) + node.ret; // remove final "comma" and add "newline"
|
||||||
}
|
}
|
||||||
else { node.warn(RED._("csv.errors.obj_csv")); }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
msg.payload = ou;
|
msg.payload = ou;
|
||||||
|
Loading…
Reference in New Issue
Block a user