| title |
|---|
r-bind Directive |
r-bind is Regor’s generic binding directive.
It maps to attribute binding by default, with property binding available via shorthand/flag.
<button r-bind:title="tooltip"></button>
<button :title="tooltip"></button>
<input .value="text" />
<input :value.prop="text" />:is shorthand forr-bind:and uses attribute binding..shorthand uses property binding..propflag switches:binding to property binding..camelcamelizes option key before binding.
From RegorConfig:
r-bind:*and:*useattrDirective..*and:*.propusepropDirective.:class/r-bind:classare routed toclassDirective.:style/r-bind:styleare routed tostyleDirective.
When an option is present (:title="x"), the first resolved value is used.
When binding without an option (r-bind="expr"), these forms are supported:
- Object:
{ key: value, ... } - Pair array:
['key', value](and arrays of pairs) - Flat key/value sequence:
key, value, key2, value2
Example:
<div r-bind="{ id: boxId, title: hint }"></div>
<div r-bind="[dynKey, dynValue]"></div>For template-authored dynamic option keys, Regor uses normalized dynamic markers:
<button r-bind:_d_dynamic-key_d_="value"></button>When dynamic attribute key changes, previous attribute is removed and new attribute is set.
- Attribute path handles boolean attributes and
xlink:*attributes. - For DOM properties (
value,checked,innerHTML, etc.), use.shorthand or.prop. - For component prop-object assignment, use
:context, notr-bind="{...}".
<a :href="profileUrl" :title="'Open ' + user.name">Profile</a>
<input .value="query" @input="query = $event.target.value" />
<div :class="{ active: isActive }" :style="{ color: tone }"></div>