Data binding reference¶
The sign player binds a template to the current scheduled item (or gap) through a handful of HTML attributes. This page is the reference for their syntax and edge cases; the worked examples are on Displaying JSON values and Binding attributes with data-attribute. The fields available to bind are listed on Template data fields.
The player processes every element carrying one of these attributes each time the active
item changes, in this order: data-condition, then data-field (with data-attribute,
data-html or luxon-format deciding what the value does), then data-template-id for
lists. Put them on elements inside .your-content — on <body> they are ignored.
data-field¶
Names the value to show. The path may use dot notation, numeric indexes and bracketed keys, and the names are case-sensitive:
<div data-field="title"></div>
<div data-field="speakers[0].first_name"></div>
<div data-field="sponsors['sponsor'][0].company.name"></div>
<div data-field="metadata['room-name']"></div>
Use brackets with quotes for a key that contains a dot or punctuation. A key that contains a
space cannot be bound this way: the attribute is split on spaces before the paths are
resolved (see the next paragraph), so metadata["room name"] is read as two broken paths.
Read such a value in script.js instead.
The path parser is lenient rather than strict: it picks out the segments it recognizes and
ignores the rest, so a mistyped path (title., .title, user..name) may still resolve
to a value, and one with unmatched quotes or brackets resolves to whatever its readable
segments point at — usually nothing. Check the sign's console when a binding shows the
wrong value.
Several fields in one element. A space-separated list joins the values with a space:
data-field="first_name last_name" shows John Doe. A missing part is left out.
What the value does depends on the other attributes on the element:
| Together with | Result |
|---|---|
| nothing else | The value becomes the element's text; existing text is a placeholder until data arrives |
data-attribute="name" |
The value is set as that attribute instead (nothing is written as text) |
data-html="true" |
The value is inserted as HTML |
luxon-format="…" |
The value is parsed as a date-time and formatted — see Time formatting |
data-template-id="id" and the value is an array |
One copy of the <template> per element — see below |
Missing fields. Numbers and booleans are shown as text. What happens when the path does
not exist in the data, or holds null, depends on where the element sits — the three
binding passes differ:
| Where the element is | Path missing | Value is null |
|---|---|---|
| Directly in a room template (the active item or gap) | Text, HTML or the attribute is cleared, so nothing from the previous item lingers; the console logs Data field "…" not found in data object, except during a gap | Shown as empty |
Inside a repeated <template> row (lists, upcoming items, daily schedule) |
The element is left as authored — placeholder text in the row template stays visible | Shown as empty |
| Anywhere in an event scoped template | The element is left untouched, so a value from the previous render stays until a later render writes a new one | Left untouched |
The table describes ordinary content binding — text and HTML. Two exceptions: with
data-attribute, a null value in a room template or a repeated row is written as the
literal attribute value null (guard such fields with data-condition); with
luxon-format, a missing, null or unparsable value clears the element and hides it
(display: none) in every pass, and a later valid value shows it again — see
Time formatting.
For rows, keep the row template free of placeholder text or guard it with data-condition;
in an event scoped template, bind fields that every item carries, or clear the element in
script.js when a field can disappear.
data-condition¶
A JavaScript expression evaluated with the current item's fields in scope. The element is
shown when it is truthy; when it is falsy, an element directly in a room template or anywhere
in an event scoped template is hidden (display: none) and stays in the DOM, while an element
inside a repeated <template> row of a room template is removed from that row:
<div data-condition="role === 'Speaker'"></div>
<div data-condition="time_start && time_end"></div>
<div data-condition="status !== 'Cancelled'"></div>
<div data-condition="role === 'Speaker' && status === 'Active'"></div>
<div data-condition="system_is_gap === true"></div>
A bare field name (data-condition="sessionCode") hides the element when the field is
missing or empty. An expression that throws — a syntax error, or a reference to a field the
item does not have — counts as false, and in a room template is logged as Failed to evaluate
condition.
The exception is a name something else on the sign already has. A name the item does not have
falls through to the browser and then to the page: location and top are the browser's own,
!name is true because the browser's name is empty, and speaker finds
<div id="speaker"> if the template has one. Those conditions don't fail, so the element can
show on items without the field. Check against in
Validate Template reports them.
Keep conditions read-only. Assignments (title = 'x'), function calls with side effects and
anything built from untrusted data belong in script.js, not in an attribute.
data-attribute¶
Writes the data-field value into the named attribute instead of the element's text:
src, href, title, alt, class, style, or a custom data-* attribute for CSS to
target. The attribute is only touched when the value changes, so an <img> or <iframe>
is not reloaded on every refresh. Values are not sanitized: avoid onclick, onload and
other event-handler attributes, and javascript: URLs.
data-html¶
data-html="true" inserts the value as HTML rather than text. Use it only for fields you
control; untrusted HTML in an item can break the layout or run script on the sign.
data-template-id and lists¶
When data-field resolves to an array, data-template-id names a <template> whose
content is cloned once per element, with that element as the data scope for the bindings
inside it:
<ul data-field="speakers" data-template-id="speaker-row"></ul>
<template id="speaker-row">
<li data-field="first_name last_name"></li>
</template>
The container is emptied before each render, so an empty array shows nothing. If the full
path does not resolve but its first segment is an array (speakers.speaker when the item
has a plain speakers array), that array is used.
Template IDs must be valid HTML IDs — letters, digits, hyphens, underscores — and unique
within the scope they are looked up in. Lookup is nearest-scope first: inside a cloned
fragment, a <template> placed within that fragment wins over one in the main document with
the same ID, and the document is the fallback. This lets a repeated item carry its own helper
templates for nested lists; do not reuse one helper ID twice inside the same repeated block.
The schedule containers (data-upcoming-items, data-daily-schedule, data-event-rooms,
data-event-timeline) use the same attribute to name their row template.