Problem calling context data from template node [Solved]

#1

Hey, I am having trouble recalling context data (a url) from a template node and wondered if anyone else
has had this problem. I am able to successfully store and recall the context data with function
nodes but when I call {{flow.url}} from a template node the url gets corrupted like this...

"https://ifttt.com/maker_webhooks?utm_medium=Blog&utm_source=Updates&utm_campaign=Maker_Launch&utm_term=&utm_content="

I am able to store the data with this...

var url = "https://ifttt.com/maker_webhooks?utm_medium=Blog&utm_source=Updates&utm_campaign=Maker_Launch&utm_term=&utm_content=";
flow.set("url", url);

var msg = {payload: url};
return msg;

I can recall the data with this...

var url = flow.get("url");
var msg = {payload: url};

return msg;

This sample flow reproduces the problem that I'm having with my sequence.

[{"id":"7d0bfbf5.fd7394","type":"inject","z":"2cafdd25.3078f2","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":140,"y":440,"wires":[["67aad8da.f5b778"]]},{"id":"67aad8da.f5b778","type":"function","z":"2cafdd25.3078f2","name":"set url","func":"var url = \"https://ifttt.com/maker_webhooks?utm_medium=Blog&utm_source=Updates&utm_campaign=Maker_Launch&utm_term=&utm_content=\";\nflow.set(\"url\", url);\n\nvar msg = {payload: url};\nreturn msg;","outputs":1,"noerr":0,"x":300,"y":440,"wires":[["4e48538b.5f3f84"]]},{"id":"4e48538b.5f3f84","type":"template","z":"2cafdd25.3078f2","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{{flow.url}}","output":"str","x":460,"y":440,"wires":[["870cfcb1.34446"]]},{"id":"870cfcb1.34446","type":"debug","z":"2cafdd25.3078f2","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":650,"y":440,"wires":[]},{"id":"6cdad2d0.fc446c","type":"inject","z":"2cafdd25.3078f2","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":140,"y":500,"wires":[["53bf0e04.f8fb1"]]},{"id":"53bf0e04.f8fb1","type":"function","z":"2cafdd25.3078f2","name":"get url","func":"var url = flow.get(\"url\");\n\nvar msg = {payload: url};\n\nreturn msg;","outputs":1,"noerr":0,"x":300,"y":500,"wires":[["2ff5a4ca.2db824"]]},{"id":"2ff5a4ca.2db824","type":"debug","z":"2cafdd25.3078f2","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":650,"y":500,"wires":[]},{"id":"c607efa3.7a64c8","type":"comment","z":"2cafdd25.3078f2","name":"flow.set('url') and flow.get('url')","info":"","x":190,"y":380,"wires":[]}]

Any help would be great.

0 Likes

#2

By default, mustache html-escapes values. As described in the sidebar help, you can use {{{ triple braces }}} to stop that.

0 Likes

#3

Thanks so much, it's working now.

0 Likes