Read control nodes and generate HTML text

This example explains how to read control nodes and use the text widget’s HTML feature to style text.

Widget used

Functions covered

Load this example composition to follow along in a real composition.

Composition structure

The composition has one sub-composition called Lower, as you can see in the composition tree.

To see this sub-composition's widgets:

  1. Open the composition script editor within the same example composition as above and select the Lower composition script.

  2. In the composition navigator, select the Widget Explorer tab.

This composition contains three widgets, but for this quick start, you'll look at the text widget, which in the composition is called lowerFullname.

Composition script

Now that you have located the composition's text widget, learn how to use the text widget’s HTML feature to style text and set a background color in the Lower composition script.

You can also copy and paste the composition script below into your own compositions.

Lower script
(function() {

  const HTML_TEMPLATE = "<html>{{firstname}} <b>{{lastname}}</b></html>";

  return {

    init: function(comp, context) {

      // get reference to the fullname widget
      const wiLowerFullname = comp.findWidget("lowerFullname")[0];


      // we define a function to update the composition
      function updateComposition() {
        // get control node payload as JSON object
        const p = comp.getPayload2();

        // build HTML text.
        let htmlFullname = HTML_TEMPLATE.replace("{{firstname}}", p["Firstname"]);
        htmlFullname = htmlFullname.replace("{{lastname}}", p["Lastname"]);

        // update fullname text
          "text": htmlFullname



      // we listen to payload_changed events
      comp.addListener('payload_changed', (event, msg, e) => {


      // update the composition when loading the output URL


    close: function(comp, context) {}

Singular control app

Last updated