Passing msg.payload into template node <script>

this IS working. the code is within <script></script> tag in the template node.

The only trouble is the data coming into this function is from a static data within the template. I want the static data wihtin the template node script tag to read from a msg.payload input.

I know the answer is in this thread, but i cant get it to adapt to my situation.
the example works for me, i just can't adapt to my requirement.