Template References

Any non-trivial UI will require using multiple templates. Here are all the ways you can include one template within another.

Inline Templates#

The most common way of including templates is by inlining them directly into your view tree. In the view menu, you can select a view's type. In the pictured example you can we've selected that we want the view "My Button" to be a Template view. At the top of the property pane is a widget for selecting which template to show in this view.

Here we've selected a template named "Button" which has two inputs "activate" and "label". You can see the two values right below the template reference and above the new event and new property buttons.

"Button" isn't anything special, it's just another template in the project.

What will happen in our hello world UI is that our view "My Button" will act as though you copied the entire contents of the "Button" template and pasted it where our view is in the view tree.

Any properties set, in this example "Inset Left" and "Inset top", will be merged with the referenced template's root view. If our "Button" template had an "Inset Top" property for example, it would be overwritten with the value 30 PX.

Views with inlined templates can use placeholder views by having children views with matching names as the referenced template's placeholder view names.

Inline Templates as List#

The "List" options is very similar to the "Template" view type as described above. The difference is that instead of including the referenced template as a single widget, it includes it once for each item in a list of data. The picture above shows our same "Button" template being included but we've changed our view's type to "List". It automatically adds a special List input to the view that can be connected up to a Source Node, Data Node, or any other source of list data.

The "Template Override" button works the same way as Map Nodes and let's you override a member of the list type to provide a single value that is used for each item in the list.

Scene Nodes#

The top portion of Scene Nodes are used to specify which template will be used as the root when shown. A button widget isn't what you'd typically use as a scene root, something like "Options Screen" or "Pop-up" would be more likely. But I show it being used here to help demonstrate the similarities when using a template reference in all possible locations.

Map and Call Nodes#

Map Nodes and Call Nodes are a bit different as referenced templates are Processing Templates, which do not produce views but only process data. Processing templates can only be used in Map and Call nodes while normal templates can only be used in the view tree or scene nodes.