# TemplateBinding

class

Describes a binding created by the [`bind`](module_ui_template-Template.md#static-function-bind) interface.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-ui/src/template.ts#L883)

<a id="properties">

## Properties

<a id="member-attribute">

### `attribute: string` _(readonly)_

The name of the [observed attribute](#member-observable).

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-ui/src/template.ts#L887)

<a id="member-callback">

### `callback?: ( value: any, node: Node ) => TemplateSimpleValue` _(readonly)_

A custom function to process the value of the [`attribute`](#member-attribute).

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-ui/src/template.ts#L908)

<a id="member-emitter">

### `emitter: Emitter` _(readonly)_

An [`Emitter`](module_utils_emittermixin-Emitter.md) used by the binding to:

* listen to the attribute change in the [`observable`](#member-observable),
* or listen to the event in the DOM.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-ui/src/template.ts#L903)

<a id="member-observable">

### `observable: Observable` _(readonly)_

An observable instance of the binding. It either:

* provides the attribute with the value,
* or passes the event when a corresponding DOM event is fired.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-ui/src/template.ts#L895)

<a id="methods">

## Methods

<a id="function-constructor">

### `constructor( def = { def.attribute, def.callback?, def.emitter, def.observable } )`

Creates an instance of the [`TemplateBinding`](module_ui_template-TemplateBinding.md) class.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-ui/src/template.ts#L915)

#### Parameters

* `def: object`

  The definition of the binding.

  Properties

  * `def.attribute: string`
  * `def.callback?: ( value: any, node: Node ) => TemplateSimpleValue`
  * `def.emitter: Emitter`
  * `def.observable: Observable`

<a id="function-activateAttributeListener">

### `activateAttributeListener( schema, updater, data ) → () => void`

Activates the listener which waits for changes of the [`attribute`](#member-attribute) in [`observable`](#member-observable), then updates the DOM with the aggregated value of [`TemplateValueSchema`](module_ui_template-TemplateValueSchema.md).

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-ui/src/template.ts#L952)

#### Parameters

* `schema: Array<TemplateSimpleValue | TemplateBinding>`

  A full schema to generate an attribute or text in the DOM.

* `updater: Updater`

  A DOM updater function used to update the native DOM attribute or text.

* `data: RenderData`

  Rendering data.

#### Returns

* `() => void`

  A function to sever the listener binding.

<a id="function-getValue">

### `getValue( node ) → TemplateSimpleValue`

Returns the value of the binding. It is the value of the [`attribute`](#member-attribute) in [`observable`](#member-observable). The value may be processed by the [`callback`](#member-callback), if such has been passed to the binding.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-ui/src/template.ts#L936)

#### Parameters

* `node: Node`

  A native DOM node, passed to the custom [`callback`](#member-callback).

#### Returns

* `TemplateSimpleValue`

  The value of [`attribute`](#member-attribute) in [`observable`](#member-observable).

---

Full index of the CKEditor 5 API reference: [llms.txt](llms.txt)
