Skip to main content

CotomyViewRenderer

Applies API response data to DOM elements using data-cotomy-bind and custom renderers.

Constructor

  • new CotomyViewRenderer(element: CotomyElement, bindNameGenerator: ICotomyBindNameGenerator) Creates a renderer bound to a root element and a bind name generator.

Properties

PropertyTypeDescription
localestringCurrent locale derived from data attributes or browser language.
initializedbooleantrue once default renderers are registered.
renderersRecord<string, (element, value) => void>Registered renderer map (initializes on access).

Methods

MethodDescription
renderer(type, callback)Registers a custom renderer for a bind type.
initialize()Registers default renderers (mail, tel, url, number, utc, date).
bindPrimitiveValue(propertyName, value)Binds a primitive value to matching elements.
applyArrayAsync(values, propertyName)Binds array values recursively.
applyObjectAsync(target, propertyName?)Binds object values recursively.
applyAsync(response)Applies the response JSON to bound elements.