# TemplateIfBinding

class

Describes a binding to [`Observable`](module_utils_observablemixin-Observable.md) created by the [`if`](module_ui_template-BindChain.md#function-if) method.

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

<a id="properties">

## Properties

<a id="member-attribute">

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

The name of the [observed attribute](module_ui_template-TemplateBinding.md#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`](module_ui_template-TemplateBinding.md#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`](module_ui_template-TemplateBinding.md#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="member-valueIfTrue">

### `valueIfTrue?: string` _(readonly)_

The value of the DOM attribute or text to be set if the [`attribute`](module_ui_template-TemplateBinding.md#member-attribute) in [`observable`](module_ui_template-TemplateBinding.md#member-observable) is `true`.

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

<a id="methods">

## Methods

<a id="function-constructor">

### `constructor( def )`

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

#### Parameters

* `def: object & object`

<a id="function-activateAttributeListener">

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

Activates the listener which waits for changes of the [`attribute`](module_ui_template-TemplateBinding.md#member-attribute) in [`observable`](module_ui_template-TemplateBinding.md#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`](module_ui_template-TemplateBinding.md#member-attribute) in [`observable`](module_ui_template-TemplateBinding.md#member-observable). The value may be processed by the [`callback`](module_ui_template-TemplateBinding.md#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#L1046)

#### Parameters

* `node: Node`

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

#### Returns

* `TemplateSimpleValue`

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

---

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