# \`template\` node. Not understanding all that is written

**URL:** https://discourse.nodered.org/t/template-node-not-understanding-all-that-is-written/19670
**Category:** General
**Created:** [28 December 2019 06:12 UTC](https://discourse.nodered.org/t/template-node-not-understanding-all-that-is-written/19670 "2019-12-28T06:12:52Z")
**Posts on this page:** 17
**Page:** 2

<div class="post-metadata">

### Author: ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)
#### Post date: [28 December 2019 09:04 UTC](https://discourse.nodered.org/t/template-node-not-understanding-all-that-is-written/19670/21 "2019-12-28T09:04:38Z")

</div>

Andrew, maybe this will help you understand W  
hat is going on: [A guide to understanding 'Persistent Context'](https://discourse.nodered.org/t/a-guide-to-understanding-persistent-context/4115)

---

<div class="post-metadata">

### Author: ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)
#### Post date: [28 December 2019 09:27 UTC](https://discourse.nodered.org/t/template-node-not-understanding-all-that-is-written/19670/22 "2019-12-28T09:27:30Z")

</div>

Thanks Paul.

(Is it me or what?)

My config file - extract:

```auto
    functionGlobalContext: {
        // os:require('os'),
        // octalbonescript:require('octalbonescript'),
        // jfive:require("johnny-five"),
        // j5board:require("johnny-five").Board({repl:false})
    },

```

That is the closest I can get to what is in the link:

```auto
    contextStorage: {
    	storeName : { module: "storeModule" }
    },

```

Please explain why I am not seeing what I should/want to see.

---

<div class="post-metadata">

### Author: ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)
#### Post date: [28 December 2019 09:32 UTC](https://discourse.nodered.org/t/template-node-not-understanding-all-that-is-written/19670/23 "2019-12-28T09:32:33Z")

</div>

What are you trying to accomplish ?

This part:

> contextStorage: {  
> storeName : { module: "storeModule" }  
> },

Only explains _ **how** _ it is used, read the post further.

> `storeModule` : Node-RED provides two built-in store modules: `memory` and `localfilesystem` . It is also possible to create custom store plugins. You must specify localfilesystem (or your own custom module) to make the data persistent. For details on creating custom modules, see the api pages.

---

<div class="post-metadata">

### Author: ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)
#### Post date: [28 December 2019 09:39 UTC](https://discourse.nodered.org/t/template-node-not-understanding-all-that-is-written/19670/24 "2019-12-28T09:39:58Z")

</div>

I'm not trying to accomplish anything.

I just read the help for the `template` node and I couldn't understand what was written down and what it means.

The names used in the example posted and what I see in my config file aren't the same.  
Or I can't see them as the same. If the latter is true, I have another problem which as yet I haven't identified.

---

<div class="post-metadata">

### Author: ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)
#### Post date: [28 December 2019 09:49 UTC](https://discourse.nodered.org/t/template-node-not-understanding-all-that-is-written/19670/25 "2019-12-28T09:49:35Z")

</div>

> [@bakman2](#):
>
> In this case: `flow.get("bla")` becomes `{{flow.bla}}` in the template node. The `store` option is used to specify the store configured in settings.js (which will default to `default` if not specified) ie you could read it from the memory store or from disk, both depending on how it is configured in settings.js.

This may be my biggest sticking point.

Can someone re-word this using the `store` option but not using the word STORE as that seems to be confusing me.

---

<div class="post-metadata">

### Author: ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)
#### Post date: [28 December 2019 09:54 UTC](https://discourse.nodered.org/t/template-node-not-understanding-all-that-is-written/19670/26 "2019-12-28T09:54:34Z")

</div>

It is a store, some space that contains things, or by definition:

> something that is stored or kept for future use

---

<div class="post-metadata">

### Author: ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)
#### Post date: [28 December 2019 09:56 UTC](https://discourse.nodered.org/t/template-node-not-understanding-all-that-is-written/19670/27 "2019-12-28T09:56:58Z")

</div>

In a very small way I get what you are saying, but _90%_ of me isn't.

The kink is the word STORE. I get that it can be a place where things are stored. Noun.

But the parsing system is stuck on the verb meaning.

So it isn't _working_ for me when I try to read and understand it.

It seems it is a problem I need to fix. I need to work on it from my end.  
I'll stop _wasting your time_.

---

<div class="post-metadata">

### Author: ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)
#### Post date: [28 December 2019 09:57 UTC](https://discourse.nodered.org/t/template-node-not-understanding-all-that-is-written/19670/28 "2019-12-28T09:57:44Z")

</div>

You are missing the point:

> [@bakman2](#):
>
> kept for future use

It is a noun.

If you want food, you go to the food-store, because it is kept there.

---

<div class="post-metadata">

### Author: ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)
#### Post date: [28 December 2019 10:27 UTC](https://discourse.nodered.org/t/template-node-not-understanding-all-that-is-written/19670/29 "2019-12-28T10:27:46Z")

</div>

> [@Trying\_to\_learn](#):
>
> Please explain why I am not seeing what I should/want to see.

As Dave tried to explain - you may need to add this to your settings.js if your node-red was initially installed before version 0.19.0

this is the **format** of the contextStore option

```auto
    contextStorage: {
    	storeName : { module: "storeModule" }
    },

```

you can use what ever name you want for `storeName`, you could call it 'andrew'. Than would mean that if you wanted to use it in a function node you would use `flow.get("foo", "andrew")`.  
if you use `default` for the `storeName` in `settings.js` you don't need to provide it in the statements.

---

<div class="post-metadata">

### Author: ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)
#### Post date: [28 December 2019 10:54 UTC](https://discourse.nodered.org/t/template-node-not-understanding-all-that-is-written/19670/30 "2019-12-28T10:54:15Z")

</div>

> [@zenofmud](#):
>
> you can use what ever name you want for `storeName` , you could call it 'andrew'.

But, and I really want to stress this point, you _only_ need to do this if you want to enable the Persistable Context option.

You don't need to do that.

---

<div class="post-metadata">

### Author: ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)
#### Post date: [28 December 2019 11:48 UTC](https://discourse.nodered.org/t/template-node-not-understanding-all-that-is-written/19670/31 "2019-12-28T11:48:04Z")

</div>

> [@Trying\_to\_learn](#):
>
> I'm not trying to accomplish anything

If your flow is working I’d not break it.

---

<div class="post-metadata">

### Author: ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)
#### Post date: [28 December 2019 19:48 UTC](https://discourse.nodered.org/t/template-node-not-understanding-all-that-is-written/19670/32 "2019-12-28T19:48:26Z")

</div>

@dceejay, @knolleary, @zenofmud, @bakman2 and others.

Ok, I had a night's sleep on the _problem_ and this is what I now have resolved:

`flow[store].name`

That is where I fall over in a heap understanding.

It wasn't until post #15 that it was mentioned that this/these lines were not put in the config because I was upgrading from a previous version.

Post #18 it was said that things are STORED, but to be more precise:

> [@bakman2](#):
>
> it is not "STORING", it is reading the store, which store ? The one you specify.

I think **THIS** is the most up to date thinking which still has me confused.

The word store can be a noun or a verb.  
You go into a _store_ to buy things and when you find that for which you are searching you _buy_ it and leave the _store_.

So drilling down to the next level:

I go into a _store_ to _buy_ some **food**.

When I leave the _store_ I don't have _store_. I have _food_.

So when the line:  
`flow[store].name`  
is used the names use are so wrong it is blowing my mind.

`flow[food].name` maybe.

But then there are still two questions:

What part is the `.name` and why the `[]` around the name?

The `[]` imply to me from past use that it is an array.  
eg: `somthing[0], something [1], something[2]` and so on.

So although I am _wrong_ in my thinking, anyone else who thinks like me is in for a real hard time trying to parse how to structure that line. What is what.

I am not trying to be difficult. I am merely saying what I am seeing and how confused I am because of it.

Anyway, I'll try to move on from it as I really don't have any persistent variables. Though: "sure as eggs" I will soon need them.

---

<div class="post-metadata">

### Author: ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)
#### Post date: [28 December 2019 20:04 UTC](https://discourse.nodered.org/t/template-node-not-understanding-all-that-is-written/19670/33 "2019-12-28T20:04:54Z")

</div>

> I go into a _store_ to _buy_ some **food**.

So read it like: You go to the store to get a variable, which store ? the store you specify and was defined in settings.js (as was pointed out earlier: this part of the configuration does not exist when upgrading)

Example stores:

```auto
 contextStorage: {
    	default : { module: "memory" },
		storeInFile: { module: "localfilesystem"},
		memoryOnly : { module: "memory" }
    },

```

I don't understand the focus on this "store" thing, because you can use persistent variables and still don't have to deal with the "store"

---

<div class="post-metadata">

### Author: ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)
#### Post date: [28 December 2019 20:10 UTC](https://discourse.nodered.org/t/template-node-not-understanding-all-that-is-written/19670/34 "2019-12-28T20:10:36Z")

</div>

To expand on this, relating it back to the original question about the Template node, if you had context configured as described in @bakman2's reply, you could then use:

```auto
{{flow[storeInFile].foo}}

```

To retrieve the flow context variable `foo` that had been saved in the `storeInFile` store.

You ask why is it that syntax... We'll, because that's the syntax we have.

If you don't have any contextStorage configured, then your context values will be stored in the default memory-only store. And in that case, you don't have to tell NR which store to use because there is only one.

---

<div class="post-metadata">

### Author: ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)
#### Post date: [28 December 2019 20:18 UTC](https://discourse.nodered.org/t/template-node-not-understanding-all-that-is-written/19670/35 "2019-12-28T20:18:54Z")

</div>

@knolleary,

Again: I must agree with what you say.

But for a _noob_ like me it is confusing.

`{{flow[storeInFile].foo}}`

Would maybe have gone a long way to reduce the confusion for me. I honestly can't say.

But again - and remember: I am not trying to be difficult - with the syntax history I have seen I would have made it more like:  
~~`{{flow.storeInFile[foo]}}`~~

Maybe:  
`{{flow.storeInFileName[foo]}}`

That way it is shown you have the filename which is used (set if the settings.js file) and what it is (as a sort of array) you want to get.

Sorry I have seemed to be so stubborn about it. It was just so confusing because I wasn't brought up on that kind of syntax and how I saw it: it was confusing.

Thanks to all who helped. Really.

I'm not going to say I will suddenly get it. But I have been shown what it means I will have to remember this _quirk_ in what to do. Because as I have said, it is most likely not going to be long before I am using persistent variables who survive a reboot.

---

<div class="post-metadata">

### Author: ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)
#### Post date: [28 December 2019 20:27 UTC](https://discourse.nodered.org/t/template-node-not-understanding-all-that-is-written/19670/36 "2019-12-28T20:27:04Z")

</div>

> [@Trying\_to\_learn](#):
>
> Because as I have said, it is most likely not going to be long before I am using persistent variables who survive a reboot.

And then you still don't have to deal with it, consider yourself lucky 😉

---

<div class="post-metadata">

### Author: ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)
#### Post date: [28 December 2019 20:28 UTC](https://discourse.nodered.org/t/template-node-not-understanding-all-that-is-written/19670/37 "2019-12-28T20:28:48Z")

</div>

Yeah, but when I get to that bridge I want to be as knowledgeable as possible before then.

Because: though not that difficult, I am sure you can appreciate from this whole debarcle (spelling?) it is not going to be smooth for me.

[Previous page](https://discourse.nodered.org/t/template-node-not-understanding-all-that-is-written/19670.md?page=1)
