In custom layout tabs, it is possible to add an inline HTML fragment. The HTML content of this fragment is restricted to selected tags and attributes (see below). It can be used to insert custom UI elements into the template. The HTML button can also be linked to a click-handler in internal scripting, enabling the possibility to add special functionality when the user clicks the button. The HTML fragments are stored inside the template, so no need to host these fragments on a web server.
CSS can be set in style attributes or in a <style> element. Rules in a <style> element, also inside @media, apply only to the fragment. Other at-rules, such as @keyframes, are added unchanged, and @import is removed. External style sheets are not supported.
Adding an HTML Fragment
The inline HTML fragment can only be added to custom layout tabs. Fragments added to the auto-generated All tab in earlier versions are still shown in the field tree, where they can be edited, renamed and deleted.
Adding an HTML Fragment to the Custom Layout Tabs
For the Custom Layout tabs, the UI components like HTML panels and HTML fragments, are not part of the field tree on the left. They are placed in the custom layout tab, and are listed in the component tree, which is opened with Toggle component tree at the right end of the tab row. See Template Layout.
To add an inline HTML fragment into a custom layout tab, follow these steps:
Create or select a custom layout tab.
In the middle toolbar, click the Add HTML fragment to current view button.
Enter an ID for the fragment.
A new HTML fragment is now added to the form.
Click the ruler to toggle edit and view mode: .
In the field editor for HTML fragments the maximum height can be set and the HTML can be entered. See below for HTML tag and attribute limitations for the HTML entered into the box. It is also possible to enter a Hidden- or Read-Only expression for this panel. See Hidden and Read-only Expressions.
Z-order
The Z-order of the components follows their order in the component tree. Drag them in the component tree to change it; the same order is also the tab order. The first component added to the form is in the back layer, then each component added has a higher Z-index, and the last component added is on top.
Use Inline Bindings
From inside HTML fragments, it is possible to use values from fields and environment variables. Examples:
HTML fragment | Note |
|---|---|
| Display the value from the field called 01-HEADLINE. |
| Use the value of the built-in environment variable “PDS” and use it in a URL. |
| Use the user-defined environment variable “version”. This variable can be defined in a URL parameter to Viz Pilot Edge or Template Builder, for instance: https://pds-host:7373/app/templatebuilder/templatebuilder.html?$version=4-0 |
| Display the value of the key |
Info: The field binding is supported for the following field types: Single- and multiline, numbers, boolean and date.
Use Input Bindings
In HTML fragments it is possible to two-way bind data between HTML input fields and internal scripting:
Use the vizrt-input-name attribute to bind the control:
Example 1 - Bind to Field
<input vizrt-input-name="title" type="text" value="MATCH DAY">
This binds the value of the input box to the field “title” in the template.
Example 2 - Bind to Scripting
<input vizrt-input-name="$data.home_score" type="number" value="0">When the input changes, the template script's vizrt.onDataChanged(key, value, oldValue) is called with the key without $data.. It is not called for changes made by the script itself, when the value is unchanged, or when the script starts with a new $data.
vizrt.onDataChanged = (key, value, oldValue) => { if (key === "home_score") { // Do something }}See Action Panels for more information.
Embed a Field Editor
<field path="title"></field> shows the regular editor of the field title inside the fragment. The label-class attribute sets a CSS class on the label of the editor.
Adding a Clickable Button
Inside an HTML fragment, it is possible to add an HTML button. Scripting inside HTML fragments is not allowed, but there is a way to add an event handler to the button to enable internal template scripting on click.
Add a <button> in the HTML fragment.
Add a special attribute vizrt-click-name to the button, specifying how a click on this button can be identified in internal scripting.
Add an internal script event handler for onClick and check for the value of the attribute above.
In the HTML fragment:
<button vizrt-click-name="updatebutton">UPDATE</button>The name can then be checked for internal template scripting:
vizrt.onClick = (name: string) => { if (name === "updatebutton") { // Do something }}Example
Inside the HTML fragment, you can use HTML tags without scripting or links, with CSS in style attributes or in a <style> element. This is due to security and layout reasons, but there is quite a lot of flexibility.
<p style="color: red;">This text is red.</p><div style="background:black;width:200%;height:100px">Background black</div> <p style="position:absolute; top:100px; left:200px; background:white; color:blue;font-size:26px;"> I'm a big, blue, <strong>strong</strong> paragraph </p><img src="https://picsum.photos/100"><button vizrt-click-name="updatebutton">UPDATE</button>You then have the following panel:
Allowed HTML Tags and Attributes
CSS can be set in style attributes or in a <style> element in the fragment. External style sheets are not supported.
White-listed Tags
ABBR | DETAILS | I | Q | THEAD |
Black-listed Tags
These tags cannot be used in inline HTML fragments, either because they expose a security risk, they conflict with the application, they need to be bound to script, or they make no sense inside the <BODY> of an HTML fragment.
AREA | EMBED | NAV | SVG | TITLE |
White-listed Attributes
These are the allowed attributes inside tags in an HTML fragment.
The attributes must be in lower case: alt, class, datetime, height, kind, label, name, src, srclang, style, title, type, value, width, plus vizrt-click-name, vizrt-input-name, and path and label-class for <field>. Other attributes, including id, are not allowed. A fragment with a tag or attribute that is not allowed shows an error with the line number instead of its content.


