# Mustache Template Buffer Out

**URL:** <https://discourse.nodered.org/t/mustache-template-buffer-out/19196>\
**Category:** General\
**Created:** [15 December 2019 19:31 UTC](https://discourse.nodered.org/t/mustache-template-buffer-out/19196 "2019-12-15T19:31:56Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![gilad](https://avatars.discourse-cdn.com/v4/letter/g/5f9b8f/32.png) [@gilad](https://discourse.nodered.org/u/gilad)\
**Post date:** [15 December 2019 19:31 UTC](https://discourse.nodered.org/t/mustache-template-buffer-out/19196/1 "2019-12-15T19:31:57Z")

</div>

Hi all,

I'm using an HTML code through mustache template node, as below:

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/6/6b0dffcacf9bde5f07b314562f7c6ac08ba3175d.png)

The Idea is to get a "true" and complete buffer output in the first "1-string buffer" debug node, as in the second debug node "2-Buffer".  
The problem is that the template node "image" outputs only text of the code itself, and not the smiley image as in the HTTP out: "[http://127.0.0.1:1880/myimage](http://127.0.0.1:1880/myimage)"

Here's the flow:

```auto
[{"id":"474e4db9.c11e94","type":"http in","z":"8561fce.5cad2","name":"","url":"/myimage","method":"get","upload":false,"swaggerDoc":"","x":120,"y":980,"wires":[["737221c3.4437b"]]},{"id":"737221c3.4437b","type":"template","z":"8561fce.5cad2","name":"image","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"<!DOCTYPE html>\n<html>\n<body>\n\n<img src=\"https://upload.wikimedia.org/wikipedia/commons/thumb/e/e0/SNice.svg/220px-SNice.svg.png\" alt=\"Smiley face\" width=\"42\" height=\"42\">\n\n</body>\n</html>\n","output":"str","x":290,"y":960,"wires":[["d92586c.c839478","20e0cbad.f8b604"]]},{"id":"d92586c.c839478","type":"http response","z":"8561fce.5cad2","name":"","statusCode":"","headers":{},"x":430,"y":920,"wires":[]},{"id":"f412297d.781dc8","type":"debug","z":"8561fce.5cad2","name":"1-String-Buffer","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":600,"y":980,"wires":[]},{"id":"20e0cbad.f8b604","type":"http request","z":"8561fce.5cad2","name":"Post","method":"POST","ret":"bin","paytoqs":false,"url":"http://localhost:1880/myimage","tls":"","persist":false,"proxy":"","authType":"","x":430,"y":980,"wires":[["f412297d.781dc8"]]},{"id":"557afc7e.efcdd4","type":"http request","z":"8561fce.5cad2","name":"GET","method":"GET","ret":"bin","paytoqs":false,"url":"https://upload.wikimedia.org/wikipedia/commons/thumb/e/e0/SNice.svg/220px-SNice.svg.png","tls":"","persist":false,"proxy":"","authType":"","x":290,"y":1060,"wires":[["71f86078.01758"]]},{"id":"71f86078.01758","type":"debug","z":"8561fce.5cad2","name":"2-Buffer","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":480,"y":1060,"wires":[]},{"id":"aa00b974.31ada8","type":"inject","z":"8561fce.5cad2","name":"Inject","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":130,"y":1060,"wires":[["557afc7e.efcdd4"]]},{"id":"4987c6b8.bf43d8","type":"inject","z":"8561fce.5cad2","name":"Inject","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":150,"y":920,"wires":[["737221c3.4437b"]]}]

```

It seems simple, but I'm struggling with it for hours.  
Any comment and idea is highly appreciated. Thanks!  
.

---

<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:** [15 December 2019 20:26 UTC](https://discourse.nodered.org/t/mustache-template-buffer-out/19196/2 "2019-12-15T20:26:47Z")

</div>

Hi @gilad

I'm struggling to understanding what you are trying to do here.

What I can see is you have a flow (the top one) that responds to an HTTP GET request to `/myimage` with some HTML content that includes an `<img>` element with a src attribute pointed at an image hosted on wikimedia. That flow also sends that HTML as an HTTP POST to `/myimage` - but there is no flow here configured to handle that.

The second flow does an HTTP GET of the image from wikimedia.

You say you want the Debug output of `1-String-Buffer` to be the same as `2-Buffer` - but they are doing completely different things. The `1-String-Buffer` debug node will show the response of the `Post` node, but without seeing what flow you have configured to handle that, I can't say what it will output.

---

<div class="post-metadata">

**Author:** ![gilad](https://avatars.discourse-cdn.com/v4/letter/g/5f9b8f/32.png) [@gilad](https://discourse.nodered.org/u/gilad)\
**Post date:** [15 December 2019 20:59 UTC](https://discourse.nodered.org/t/mustache-template-buffer-out/19196/3 "2019-12-15T20:59:37Z")

</div>

Hello @knolleary,

Thanks for the prompt response.

I'm trying to get the first flow result " **1-String Buffer**" debug node,  
( `msg.payload : buffer[147]` )

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/2/24c1069eacbbd9363c599e5ff0c8f9ba35f83165.png)

```auto
[{"id":"474e4db9.c11e94","type":"http in","z":"8561fce.5cad2","name":"","url":"/myimage","method":"get","upload":false,"swaggerDoc":"","x":120,"y":980,"wires":[["737221c3.4437b"]]},{"id":"737221c3.4437b","type":"template","z":"8561fce.5cad2","name":"image","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"<!DOCTYPE html>\n<html>\n<body>\n\n<img src=\"https://upload.wikimedia.org/wikipedia/commons/thumb/e/e0/SNice.svg/220px-SNice.svg.png\" alt=\"Smiley face\" width=\"42\" height=\"42\">\n\n</body>\n</html>\n","output":"str","x":290,"y":960,"wires":[["d92586c.c839478","20e0cbad.f8b604"]]},{"id":"d92586c.c839478","type":"http response","z":"8561fce.5cad2","name":"","statusCode":"","headers":{},"x":430,"y":920,"wires":[]},{"id":"f412297d.781dc8","type":"debug","z":"8561fce.5cad2","name":"1-String-Buffer","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":600,"y":980,"wires":[]},{"id":"20e0cbad.f8b604","type":"http request","z":"8561fce.5cad2","name":"Post","method":"POST","ret":"bin","paytoqs":false,"url":"http://localhost:1880/myimage","tls":"","persist":false,"proxy":"","authType":"","x":430,"y":980,"wires":[["f412297d.781dc8"]]},{"id":"4987c6b8.bf43d8","type":"inject","z":"8561fce.5cad2","name":"Inject","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":150,"y":920,"wires":[["737221c3.4437b"]]}]

```

to be identical to the second flow result - **2-Buffer** debug node  
( `msg.payload : buffer[11279]` )

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/3/307364998390a2b67b480efbbdcb64c532811bfd.png)

```auto
[{"id":"557afc7e.efcdd4","type":"http request","z":"8561fce.5cad2","name":"GET","method":"GET","ret":"bin","paytoqs":false,"url":"https://upload.wikimedia.org/wikipedia/commons/thumb/e/e0/SNice.svg/220px-SNice.svg.png","tls":"","persist":false,"proxy":"","authType":"","x":290,"y":1060,"wires":[["71f86078.01758"]]},{"id":"71f86078.01758","type":"debug","z":"8561fce.5cad2","name":"2-Buffer","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":480,"y":1060,"wires":[]},{"id":"aa00b974.31ada8","type":"inject","z":"8561fce.5cad2","name":"Inject","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":130,"y":1060,"wires":[["557afc7e.efcdd4"]]}]

```

They both should represent the buffer output of this [wikimedia image url](https://upload.wikimedia.org/wikipedia/commons/thumb/e/e0/SNice.svg/220px-SNice.svg.png) example  
for further analysis and (also for Base64 conversion) , but the " **1-String Buffer**" debug node obviously returns only the buffer/string of the HTML code itself and not the image, as it will be in HTTP OUT node.

The question is how it's possible to mimic the behavior of the second flow **2-Buffer** for the first flow " **1-String Buffer**" so the outputs will be identical.

Thanks!

---

<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:** [15 December 2019 21:02 UTC](https://discourse.nodered.org/t/mustache-template-buffer-out/19196/4 "2019-12-15T21:02:30Z")

</div>

The flows are doing fundamentally different things.

The first flow is generating HTML that will be returned to your browser and your browser will load the image. The flow doesn't ever get the image data itself.

The second flow is getting the image directly.

If you want the first flow to return the image data directly, why not do it in the same way as the second flow using the HTTP Request node?
