# new RenderingEngine(flavour)
The RenderingEngine class provides a framework for converting model metadata into UI field definitions. It handles the translation of model properties to UI elements, applies validation rules, and manages different rendering flavors. This class is designed to be extended by specific rendering implementations.
Abstract class for rendering UI components based on model metadata.
Parameters:
Name | Type | Description |
---|---|---|
flavour |
string
|
The flavor of the rendering engine. |
Members
# initialized
Flag indicating whether the rendering engine has been initialized.
Flag indicating whether the rendering engine has been initialized.
boolean
# protected initialized
Flag indicating whether the rendering engine has been initialized.
Flag indicating whether the rendering engine has been initialized.
Methods
# abstract initialize(…args) → {Promise.<void>}
Abstract method to be implemented by subclasses for specific initialization logic.
Initializes the rendering engine.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
args |
Array.<any>
|
<repeatable> |
Any additional arguments needed for initialization. |
A promise that resolves when initialization is complete.
Promise.<void>
# protected isValidatableByAttribute(key) → {boolean}
Determines if a given UI key represents a validation that can be applied as an attribute.
Checks if a type is validatable by attribute.
Parameters:
Name | Type | Description |
---|---|---|
key |
string
|
The UI key to check. |
True if the type is validatable by attribute, false otherwise.
boolean
# protected isValidatableByType(key) → {boolean}
Determines if a given UI key represents a type that is inherently validatable.
Checks if a type is validatable by its nature.
Parameters:
Name | Type | Description |
---|---|---|
key |
string
|
The UI key to check. |
True if the type is validatable, false otherwise.
boolean
# abstract render(model, globalProps, …args) → {R}
Abstract method to be implemented by subclasses to define specific rendering behavior.
Renders a model with global properties and additional arguments.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
model |
M
|
The model to be rendered. |
|
globalProps |
Record.<string, unknown>
|
Global properties to be applied to all elements during rendering. |
|
args |
Array.<any>
|
<repeatable> |
Additional arguments that may be required for specific rendering implementations. |
The rendered result, type depends on the specific implementation.
R
# protected toAttributeValue(key, value) → {string|number|boolean}
Transforms validation metadata into a value suitable for use as an HTML attribute.
Converts validation metadata to an attribute value.
Parameters:
Name | Type | Description |
---|---|---|
key |
string
|
The validation key. |
value |
ValidationMetadata
|
The validation metadata. |
If the given key is not validatable by attribute.
Error
The converted attribute value.
string
|
number
|
boolean
# protected toFieldDefinition(model, globalPropsopt, generateIdopt) → {FieldDefinition.<T>}
Processes a model instance, extracting UI-related metadata and validation rules to create a field definition.
Converts a model to a field definition.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
model |
M
|
The model instance to convert. |
||
globalProps |
Record.<string, unknown>
|
<optional> |
{} | Global properties to apply to all child elements. |
generateId |
boolean
|
<optional> |
true | Flag indicating whether to populate the rendererId property. |
If no UI definitions are set for the model or if there are invalid decorators.
A field definition object representing the UI structure of the model.
FieldDefinition.<T>
# translate(key, toViewopt) → {string}
Converts model data types to appropriate HTML input types and vice versa.
Translates between model types and HTML input types.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
key |
string
|
The key to translate. |
||
toView |
boolean
|
<optional> |
true | Direction of translation (true for model to view, false for view to model). |
The translated type.
string
# static get(flavouropt) → {RenderingEngine.<O>}
Gets the current rendering engine or a specific one by flavor.
Retrieves a rendering engine by flavor.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
flavour |
string
|
<optional> |
The flavor of the rendering engine to retrieve. |
If the requested flavor does not exist.
InternalError
The requested rendering engine.
RenderingEngine.<O>
# static key(key) → {string}
Prefixes a given key with the UI reflection prefix.
Generates a metadata key for UI-related properties.
Parameters:
Name | Type | Description |
---|---|---|
key |
string
|
The key to prefix. |
The prefixed key.
string
# static register(engine)
Adds a rendering engine to the static cache and sets it as the current engine.
Registers a rendering engine instance.
Parameters:
Name | Type | Description |
---|---|---|
engine |
RenderingEngine.<unknown, unknown>
|
The rendering engine to register. |
If an engine with the same flavor already exists.
InternalError
# static render(model, …args) → {any}
Determines the correct rendering engine for a model and invokes its render method.
Renders a model using the appropriate rendering engine.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
model |
M
|
The model to render. |
|
args |
Array.<any>
|
<repeatable> |
Additional arguments to pass to the render method. |
If no registered model is found.
InternalError
The result of the rendering process.
any