Subflow - template node - subflow properties


How can I access any subflow property in a template - mustache - node?

(My current work around is to use a change node (with $) in combination with a template node.)

No I dont think so.
To my knowledge you can only do it from a function node with env.get("") and the way you already do it using a change node.
Best regards Johannes

I just checked with the source code. There is only a special handling for flow and global, so you can access it via {{}} or {{}}.
But none for env, though it would be a nice addition.

So copying your env variable to a message property beforehand is the only solution for now.

Why are you wanting to access a subflow property outside the subflow?

The idea of a subflow is that it is (as I see it) a Macro.

If anyone wanted to propose a PR that added support for {{env.FOO}} in the Template node, I'm sure it would be welcome.


I assume they are wanting to access it from a Template node inside the subflow.

1 Like

Ah. Again I goofed.

Ok, I am not really good with what env is compared to context, flow or global.

Would it be pushing the friendship asking?

Not at all - but lets take care not to let this topic stray too off-topic.

env is a way to access Environment Variables from within a Node-RED flow - Using environment variables : Node-RED

These are read-only values that can be set outside of Node-RED before it is started. They are useful if you want to run the same set of flows on multiple devices but need each instance to each some configuration value to be device-specific. By setting it via environment variable, you don't need to edit the flows on each device - you set the env-var before running NR.

Building on that, Subflow allow you to define your own env-vars that are defined within the scope of the subflow, or to customise on a per-instance basis.

A key difference between Env Vars and Context is that env vars are read-only and not used for runtime state that may change.

Thanks a lot for clarification.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.