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;">
|
||||
<option value="str" data-i18n="template.label.plain"></option>
|
||||
<option value="json" data-i18n="template.label.json"></option>
|
||||
<option value="yaml" data-i18n="template.label.yaml"></option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
|
@ -17,6 +17,8 @@
|
||||
module.exports = function(RED) {
|
||||
"use strict";
|
||||
var mustache = require("mustache");
|
||||
var yaml = require("js-yaml");
|
||||
|
||||
|
||||
/**
|
||||
* Custom Mustache Context capable to resolve message property and node
|
||||
@ -80,6 +82,9 @@ module.exports = function(RED) {
|
||||
if (node.outputFormat === "json") {
|
||||
value = JSON.parse(value);
|
||||
}
|
||||
if (node.outputFormat === "yaml") {
|
||||
value = yaml.load(value);
|
||||
}
|
||||
|
||||
if (node.fieldType === 'msg') {
|
||||
RED.util.setMessageProperty(msg,node.field,value);
|
||||
|
@ -195,6 +195,7 @@
|
||||
"mustache": "Mustache template",
|
||||
"plain": "Plain text",
|
||||
"json": "Parsed JSON",
|
||||
"yaml": "Parsed YAML",
|
||||
"none": "none"
|
||||
},
|
||||
"templatevalue": "This is the payload: {{payload}} !"
|
||||
|
Loading…
Reference in New Issue
Block a user