# Template node send advanced data

**URL:** <https://discourse.nodered.org/t/template-node-send-advanced-data/21314>\
**Category:** General\
**Created:** [5 February 2020 14:52 UTC](https://discourse.nodered.org/t/template-node-send-advanced-data/21314 "2020-02-05T14:52:17Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![RogierQ](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/rogierq/32/3211_2.png) [@RogierQ](https://discourse.nodered.org/u/RogierQ)\
**Post date:** [5 February 2020 14:52 UTC](https://discourse.nodered.org/t/template-node-send-advanced-data/21314/1 "2020-02-05T14:52:17Z")

</div>

I have done it before but no way i can do it again...

What i wish to do is use the template to display a webpage.  
this works perfect  
then when i want to send external data with {{msg.payload}} it works to, like this:

```auto
<td width="7%" class="flights">msg.flight1</td>

```

but what i want to do is send the whole line  
including the width and class parameters

What is the trick to do this?

i tried to put more code examples but the " and ` give lat of troubles because they tried to make html from it

---

<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:** [5 February 2020 15:59 UTC](https://discourse.nodered.org/t/template-node-send-advanced-data/21314/2 "2020-02-05T15:59:45Z")

</div>

Have you tried coding the html in msg.flight? lets say currently msg.flight is "Hello World" so instead of passing that into the template where you have  
`<td width="7%" class="flights">msg.flight1</td>`  
you set  
`msg.flight1='<td width="7%" class="flights">Hello World</td>'`  
and in the template node just use:  
`msg.flight1`

Note: I haven't tried this, so it may or may not work.

---

<div class="post-metadata">

**Author:** ![RogierQ](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/rogierq/32/3211_2.png) [@RogierQ](https://discourse.nodered.org/u/RogierQ)\
**Post date:** [5 February 2020 18:55 UTC](https://discourse.nodered.org/t/template-node-send-advanced-data/21314/3 "2020-02-05T18:55:44Z")

</div>

jup i did and that just shows msg.flight1  
but i thought there was a setting to do it correct

---

<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:** [5 February 2020 19:40 UTC](https://discourse.nodered.org/t/template-node-send-advanced-data/21314/4 "2020-02-05T19:40:51Z")

</div>

You know you could use an external file

**Using `msg.template` :**  
You can also define the template content via `msg.template` , so you can use external files for example.  
Template will be reloaded on input if it has changed.  
Code written in the Template field will be ignored when `msg.template` is present.

---

<div class="post-metadata">

**Author:** ![shrickus](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/shrickus/32/517_2.png) [@shrickus](https://discourse.nodered.org/u/shrickus)\
**Post date:** [5 February 2020 21:24 UTC](https://discourse.nodered.org/t/template-node-send-advanced-data/21314/5 "2020-02-05T21:24:24Z")

</div>

I believe you are running into Angular's logic that tries to "cleanse" the substituted variables... this keeps nefarious `<script>` tags and other elements from being inserted into the rendered page.

You can disable that (somewhat) by adding the `ng-bind-html` attribute to a container, and then inserting the chunk of html text directly from the msg.payload or other field, like so:

```auto
<div ng-bind-html="msg.payload"></div>

```

or, for you specific example, try this:  
`<tr ng-bind-html="msg.flight1></tr>`

and send the entire line of html including the `<td> ... </td>` tags -- which is not very useful if you plan on showing more than 1 row in your table.

So you have a couple options for generating an entire table of html rows: use the core `template` node and Mustache iteration to render an array of row data as plain html source:

```auto
<table>
{{#flights}}
    <tr>
        <td width="7%" class="flights">{{flight_no}}</td>
        <td>{{departure}}</td>
        <td>{{est_arrival}}</td>
    </tr>
{{/flights}}
</table>

```

Assuming you pass an array of flight "objects" with those properties, it will render 1 table row for each object in the array -- pass that rendered html to the `<div>` example above and it should draw the whole table for you.

Another option is to use the `ui_template` dashboard node, with Angular's `ng-repeat` attribute to iterate over the rows of data directly inside the browser, something like this:

```auto
<table>
    <tr ng-repeat="flight in msg.flights">
        <td width="7%" class="flights">{{flight.flight_no}}</td>
        <td>{{flight.departure}}</td>
        <td>{{flight.est_arrival}}</td>
    </tr>
</table>

```

Hope this helps...

---

<div class="post-metadata">

**Author:** ![RogierQ](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/rogierq/32/3211_2.png) [@RogierQ](https://discourse.nodered.org/u/RogierQ)\
**Post date:** [10 February 2020 19:56 UTC](https://discourse.nodered.org/t/template-node-send-advanced-data/21314/6 "2020-02-10T19:56:28Z")

</div>

thanks for your help!

---

<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:** [10 April 2020 19:56 UTC](https://discourse.nodered.org/t/template-node-send-advanced-data/21314/7 "2020-04-10T19:56:30Z")

</div>

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