Ir al contenido

Bindings

Los bindings de datos conectan elementos HTML con las sources del manifest. Todo valor dinámico en un artifact debe usar data-shareout-binding — la manipulación directa del DOM vía JavaScript oculta los valores del panel de datos del editor y el rastreador de variables.

data-shareout-binding="TYPE:PATH"
TipoSintaxisEjemplo
Key JSONjson:keyjson:settings.theme
JSON anidadojson:key.path.to.valuejson:metrics.revenue.total
Campo de fila de tablatable:name:row:$id:fieldtable:tasks:row:$id:title
Fila con ID estáticotable:name:row:ID:fieldtable:tasks:row:task-1:title
Count de tablatable:name:count:fieldtable:tasks:count:id
Count filtradotable:name:count:field:filtertable:tasks:count:id:done=true
Sum de tablatable:name:sum:fieldtable:orders:sum:amount
Avg de tablatable:name:avg:fieldtable:orders:avg:amount
Computedcomputed:namecomputed:completedCount
<!-- CORRECTO: el editor rastrea este binding -->
<span data-shareout-binding="json:metrics.revenue"
data-shareout-format="currency"
data-shareout-display="Total Revenue">$0</span>
<!-- INCORRECTO: oculto al editor -->
<span id="revenue"></span>
<script>document.getElementById('revenue').textContent = await sdk.json.get('metrics.revenue')</script>

Aplicá un formato de visualización con data-shareout-format:

<span data-shareout-binding="json:metrics.revenue"
data-shareout-format="currency">$0</span>
FormatoParámetrosEjemplo de salida
currency$1,234.56
percent12.5%
number1,234
number:00 decimales1,235
number:22 decimales1,234.56
dateMay 29, 2026
date:short5/29/26
date:longMay 29, 2026
date:iso2026-05-29
time3:45 PM
datetimeMay 29, 2026 3:45 PM

En el modo Inspect de Live Studio, los elementos con binding muestran un control Format (texto plano, número, moneda, porcentaje, fecha) que lee y escribe data-shareout-format — no hace falta editar el atributo a mano.

data-shareout-display provee una etiqueta legible que se muestra en el panel de datos del editor:

<span data-shareout-binding="json:metrics.revenue"
data-shareout-format="currency"
data-shareout-display="Total Revenue">$0</span>

Agregá data-shareout-editable="true" para permitir que quienes vean el artifact editen el valor in-place:

<input data-shareout-binding="json:settings.name"
data-shareout-editable="true"
data-shareout-validation="string:minLength=1:maxLength=100">
<input type="number"
data-shareout-binding="json:settings.goal"
data-shareout-editable="true"
data-shareout-validation="number:min=0:max=100">
<input type="checkbox"
data-shareout-binding="table:tasks:row:$id:done"
data-shareout-editable="true">
ReglaSintaxisEjemplo
Númeronumbernumber
Número con rangonumber:min=X:max=Ynumber:min=0:max=100
Stringstringstring
String con longitudstring:minLength=X:maxLength=Ystring:minLength=1:maxLength=50
Emailemailemail
URLurlurl
Patrónpattern:REGEXpattern:^[A-Z]{2}[0-9]{4}$
<!-- Contar todas las filas -->
<span data-shareout-binding="table:tasks:count:id">0</span>
<!-- Contar filas filtradas -->
<span data-shareout-binding="table:tasks:count:id:done=true">0</span>
<!-- Sum -->
<span data-shareout-binding="table:orders:sum:amount"
data-shareout-format="currency">$0</span>
<!-- Average -->
<span data-shareout-binding="table:orders:avg:amount"
data-shareout-format="currency">$0</span>

Referenciá un valor declarado en manifest.computed:

<span data-shareout-binding="computed:completedCount"
data-shareout-display="Completed Tasks">0</span>
  • Todo valor dinámico tiene data-shareout-binding.
  • No hay element.textContent = ni innerHTML = sin el binding correspondiente.
  • Los paths de binding coinciden con las keys y nombres de tabla declarados en el manifest.
  • Los bindings editables tienen tanto data-shareout-editable="true" como data-shareout-validation.
  • Manifest — declarar las sources que referencian los bindings
  • Templates — bindings dentro de contenido repetitivo usan $id e $index
  • Resumen — referencia completa de atributos