mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Added parsed YAML support for template node (#1443)
This commit is contained in:
parent
d426aaa88a
commit
f09e61a59a
@ -42,6 +42,7 @@
|
|||||||
<select id="node-input-output" style="width:180px;">
|
<select id="node-input-output" style="width:180px;">
|
||||||
<option value="str" data-i18n="template.label.plain"></option>
|
<option value="str" data-i18n="template.label.plain"></option>
|
||||||
<option value="json" data-i18n="template.label.json"></option>
|
<option value="json" data-i18n="template.label.json"></option>
|
||||||
|
<option value="yaml" data-i18n="template.label.yaml"></option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -17,6 +17,8 @@
|
|||||||
module.exports = function(RED) {
|
module.exports = function(RED) {
|
||||||
"use strict";
|
"use strict";
|
||||||
var mustache = require("mustache");
|
var mustache = require("mustache");
|
||||||
|
var yaml = require("js-yaml");
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Custom Mustache Context capable to resolve message property and node
|
* Custom Mustache Context capable to resolve message property and node
|
||||||
@ -80,6 +82,9 @@ module.exports = function(RED) {
|
|||||||
if (node.outputFormat === "json") {
|
if (node.outputFormat === "json") {
|
||||||
value = JSON.parse(value);
|
value = JSON.parse(value);
|
||||||
}
|
}
|
||||||
|
if (node.outputFormat === "yaml") {
|
||||||
|
value = yaml.load(value);
|
||||||
|
}
|
||||||
|
|
||||||
if (node.fieldType === 'msg') {
|
if (node.fieldType === 'msg') {
|
||||||
RED.util.setMessageProperty(msg,node.field,value);
|
RED.util.setMessageProperty(msg,node.field,value);
|
||||||
|
@ -195,6 +195,7 @@
|
|||||||
"mustache": "Mustache template",
|
"mustache": "Mustache template",
|
||||||
"plain": "Plain text",
|
"plain": "Plain text",
|
||||||
"json": "Parsed JSON",
|
"json": "Parsed JSON",
|
||||||
|
"yaml": "Parsed YAML",
|
||||||
"none": "none"
|
"none": "none"
|
||||||
},
|
},
|
||||||
"templatevalue": "This is the payload: {{payload}} !"
|
"templatevalue": "This is the payload: {{payload}} !"
|
||||||
|
Loading…
Reference in New Issue
Block a user