@@ -14,6 +14,7 @@ All nodes include documentation you can see in the Info sidebar tab when you sel
1414- [ Function] ( #function )
1515- [ Change] ( #change )
1616- [ Switch] ( #switch )
17+ - [ Template] ( #template )
1718
1819***
1920
@@ -104,3 +105,55 @@ There are four types of rule:
104105
105106The node will route a message to all outputs corresponding to matching rules. But
106107it can also be configured to stop evaluating rules when it finds one that matches.
108+
109+ ***
110+
111+ <h3 id =" template " ><img alt =" Template node " style =" vertical-align : middle " src =" /docs/user-guide/images/node_template.png " width =" 169px " ></h3 >
112+
113+ The Template node can be used to generate text using a message's properties to
114+ fill out a template.
115+
116+ It uses the [ Mustache] ( https://mustache.github.io/mustache.5.html ) templating
117+ language to generate the result.
118+
119+ For example, a template of:
120+
121+ {% raw %}
122+ ```
123+ This is the payload: {{payload}} !
124+ ```
125+ {% endraw %}
126+
127+ Will replace ` {% raw %}{{payload}}{% endraw %} ` with the value of the message's ` payload ` property.
128+
129+ By default, Mustache will replace certain characters with their HTML escape codes.
130+ To stop that happening, you can use triple braces: ` {% raw %}{{{payload}}}{% endraw %} ` .
131+
132+ Mustache supports simple loops on lists. For example, if ` msg.payload ` contains
133+ an array of names, such as: ` ["Nick", "Dave", "Claire"] ` , the following template
134+ will create an HTML list of the names:
135+
136+ {% raw %}
137+ ```
138+ <ul>
139+ {{#payload}}
140+ <li>{{.}}</li>
141+ {{/payload}}
142+ </ul>
143+ ```
144+ {% endraw %}
145+
146+
147+ ```
148+ <ul>
149+ <li>Nick</li>
150+ <li>Dave</li>
151+ <li>Claire</li>
152+ </ul>
153+ ```
154+
155+ The node will set the configured message or context property with the result of
156+ the template. If the template generates valid JSON or YAML content, it can be
157+ configured to parse the result to the corresponding JavaScript Object.
158+
159+ ***
0 commit comments