# Template flow context with variable names

**URL:** https://discourse.nodered.org/t/template-flow-context-with-variable-names/98417
**Category:** General
**Created:** [31 July 2025 13:15 UTC](https://discourse.nodered.org/t/template-flow-context-with-variable-names/98417 "2025-07-31T13:15:16Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![HarryPottar](https://avatars.discourse-cdn.com/v4/letter/h/bb73d2/32.png) [@HarryPottar](https://discourse.nodered.org/u/HarryPottar)
#### Post date: [31 July 2025 13:15 UTC](https://discourse.nodered.org/t/template-flow-context-with-variable-names/98417/1 "2025-07-31T13:15:16Z")

</div>

Hello,

I’m using a mustache template node to populate a value from the flow context.

`"{{{flow.config.name}}"`

This works as expected.

However, when I store multiple objects within the flow context using a variable, is there a way of using that in the template node?

```auto
msg.contextName = "foo";
const contextName = msg.contextName;
msg.payload = {
   "name": "bar"
}
flow.set(`config.${contextName}`, msg.payload);

```

```auto
msg.contextName = "bar";
const contextName = msg.contextName;
msg.payload = {
   "name": "foo"
}
flow.set(`config.${contextName}`, msg.payload);

```

I now have two objects in my config flow context.

```auto
{{{flow.config.foo.name}}
{{{flow.config.bar.name}}

```

I can use a change or function node to set these values before the template node. Ideally, it would be nice to use directly within the template,

I have tried the following without success.

```auto
{{{`flow.config.${msg.contextName}.tenantname`}}}
{{{`flow.config.${contextName}.tenantname`}}}
{{{flow.config[contextName]tenantname}}}

```

Thanks in advance.  
Harry

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [31 July 2025 13:26 UTC](https://discourse.nodered.org/t/template-flow-context-with-variable-names/98417/2 "2025-07-31T13:26:07Z")

</div>

Just use a change node to set `msg.config` to `flow.msGraphQLConfig` then you can access `{{{msg.config.tenantname}}}` and `{{{msg.config.foo.name}}}` and `{{{msg.config.bar.name}}}` in the template.

Alternatively, if it is the dynamic aspect you are trying to achieve, then use `[]` square bracket notation in a change node before hand. e.g. set `msg.whatever` to `flow.config[msg.contextName]` then use `{{{whatever}}}` in the template.

---

<div class="post-metadata">

### Author: ![HarryPottar](https://avatars.discourse-cdn.com/v4/letter/h/bb73d2/32.png) [@HarryPottar](https://discourse.nodered.org/u/HarryPottar)
#### Post date: [31 July 2025 13:50 UTC](https://discourse.nodered.org/t/template-flow-context-with-variable-names/98417/3 "2025-07-31T13:50:42Z")

</div>

Thanks for the quick response, I stated, I can use a change or function node, ideally looking to see if it can be done with just a tenmplate node

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [31 July 2025 14:08 UTC](https://discourse.nodered.org/t/template-flow-context-with-variable-names/98417/4 "2025-07-31T14:08:12Z")

</div>

> [@HarryPottar](#):
>
> ideally looking to see if it can be done with just a tenmplate node

No, mustache is "logic-less"

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [14 August 2025 14:09 UTC](https://discourse.nodered.org/t/template-flow-context-with-variable-names/98417/5 "2025-08-14T14:09:05Z")

</div>

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