Dashboard Template script with msg.payload

How can I use the objects from msg.payload inside the script-tag?
I need this information to control the layout...
Outside the script-tag it is possible, but I need it inside the script

the Info sidebar for the ui_template node has an example of accessing msg.payload from within a script.

This has some worked examples: