Documentation
¶
Overview ¶
Package template contains the template node implementation.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type TemplateConfig ¶
type TemplateConfig struct {
// Template is the template source; when empty, a runtime
// msg.template metadata property supplies it (Node-RED parity).
Template string `json:"template"`
// Syntax: "mustache" (default, Node-RED parity), "gotemplate"
// (extension-only Go text/template against msg.payload), or "plain"
// (no rendering — the template text passes through verbatim).
Syntax string `json:"syntax"`
// Field is the target property: "payload" (default) or a dotted
// message-property path when FieldType is "msg", or a context key
// (optionally "#:(store)::key") when FieldType is flow|global.
Field string `json:"field"`
// FieldType: "msg" (default), "flow" or "global" — where the
// rendered value is written.
FieldType string `json:"fieldType"`
// Output: "str" (default), "json" (parse the rendered text into
// JSON), or "yaml" (parse into a YAML value).
Output string `json:"output"`
// Format is the legacy engine alias: "json" → Output "json",
// "text" → Output "str". Ignored when Output is set.
Format string `json:"format"`
}
TemplateConfig holds configuration for the template node, mirroring Node-RED's template node fields plus the extension-only gotemplate syntax and the legacy Format alias.
type TemplateNode ¶
TemplateNode renders a Mustache template against the message (Node-RED parity), with Go text/template kept as a extension-only syntax option.
func NewTemplateNode ¶
func NewTemplateNode(node nodestore.NodeInterface, config *TemplateConfig, host nodebase.NodeHost) *TemplateNode
NewTemplateNode creates a new template node. host may be nil — the {{flow.X}} / {{global.X}} / {{env.X}} context tags then resolve to empty and flow/global field targets are dropped.
func (*TemplateNode) Execute ¶
func (n *TemplateNode) Execute(ctx context.Context, input nodestore.MessageInterface) (nodestore.MessageInterface, error)
Execute renders the template and writes the result to the configured target.