# new RezBlock()
Represents a renderable block of content within the view hierarchy.
A block wraps a source element (typically a card or other game element) and handles:
- Resolving data bindings from the source element
- Rendering the source's template with bound values
- Managing nested blocks
- Generating HTML output with appropriate CSS classes
Blocks can be nested within layouts to create complex view hierarchies. Each block maintains a reference to its parent block, enabling bindings to flow down through the hierarchy.
Special $ attributes recognized by RezBlock:
$debug_bindings- When true, logs binding information to console during render$suppress_wrapper- When true, omits the wrapper<div>around block content$parent- Reference to the parent source element in the hierarchy
Members
Methods
# bindBlocks() → {Object}
Renders all nested blocks to HTML.
Map of binding names to rendered HTML strings
Object
# bindValues() → {Object}
Creates the complete value bindings for template rendering.
Combines parent bindings with this block's bindings, adding:
block: Reference to this blockparams: The params objectsource: The source element- Source's bindAs name: The source element (aliased)
Complete bindings object for template rendering
Object
# bindings() → {Object}
Computes complete bindings including values and rendered blocks.
Complete bindings object
Object
# css_classes() → {string}
Gets the CSS classes for this block's wrapper element.
If block type is not recognized
Error
Space-separated CSS class names
string
# dereferenceBoundValue(value) → {Object|Array.<Object>}
Dereferences element references to their actual elements.
Handles both single values and arrays of values.
Parameters:
| Name | Type | Description |
|---|---|---|
value |
string
|
Object
|
Array
|
Value(s) to dereference |
The dereferenced element(s)
Object
|
Array.<Object>
# extractBindingValue(bindings, source, derefopt) → {*}
Extracts a value from a binding source.
Supports multiple source types:
- String: Treated as an element ID
- Element reference ({$ref: "id"}): Resolved to the element
- Function: Invoked with block context
- Object with binding function: Path-based resolution
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
bindings |
Object
|
Current bindings object |
||
source |
string
|
function
|
Object
|
The binding source |
||
deref |
boolean
|
<optional> |
false | Whether to dereference the result |
If source type is not recognized
Error
The extracted value
*
# getBindings(initialBindings) → {Object}
Builds the bindings object from the source element's bindings attribute.
Processes each binding specification, resolving sources to values and adding them to the bindings object with their specified prefixes.
Parameters:
| Name | Type | Description |
|---|---|---|
initialBindings |
Object
|
Initial bindings to extend |
The complete bindings object
Object
# getBlocks() → {Object}
Retrieves and instantiates nested blocks from the source's blocks attribute.
Each block specification defines a binding name and source element. The blocks are instantiated as RezBlock instances with this block as parent.
Map of binding names to RezBlock instances
Object
# getViewTemplate() → {function}
Gets the view template function for this block.
Template function that accepts bindings and returns HTML
function
# html() → {string}
Renders this block to HTML with its wrapper div.
If the source has $suppress_wrapper set, returns content without wrapper.
Complete HTML for this block
string
# instantiateBindingPath(p) → {*}
Resolves a binding path function against the source.
Parameters:
| Name | Type | Description |
|---|---|---|
p |
function
|
Path function to invoke |
The resolved value
*
# instantiateFunctionBinding(bindings, f) → {*}
Invokes a function binding with the current context.
Parameters:
| Name | Type | Description |
|---|---|---|
bindings |
Object
|
Current bindings object |
f |
function
|
The function to invoke |
The function's return value
*
# instantiateIdBinding(id) → {Object}
Resolves an element ID to its corresponding game element.
Parameters:
| Name | Type | Description |
|---|---|---|
id |
string
|
The element ID to resolve |
The resolved game element
Object
# instantiatePathBinding(path_fn, bindings) → {*}
Resolves a path binding function with current bindings.
Parameters:
| Name | Type | Description |
|---|---|---|
path_fn |
function
|
Path function to invoke |
bindings |
Object
|
Current bindings object |
The resolved value
*
# instantiatePropertyBinding(ref) → {*}
Resolves a property reference to its value.
Parameters:
| Name | Type | Description |
|---|---|---|
ref |
Object
|
Property reference with elem_id and attr_name |
elem_id |
string
|
The element ID |
attr_name |
string
|
The attribute name to read |
The attribute value
*
# parentBindings() → {Object}
Gets bindings from the parent block, if any.
Parent bindings or empty object
Object
# renderBlock() → {string}
Renders the block content using its template and bindings.
Rendered HTML content
string
# resolveBindingValue(bindings, bindingObject) → {*}
Resolves a binding object to its actual value.
Handles literal values directly, otherwise delegates to extractBindingValue for source-based resolution.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
bindings |
Object
|
Current bindings object |
|
bindingObject |
Object
|
The binding specification |
|
literal |
*
|
<optional> |
A literal value (used directly if present) |
source |
*
|
<optional> |
Source for value resolution |
deref |
boolean
|
<optional> |
Whether to dereference the result |
If source is undefined or null when no literal is provided
Error
The resolved binding value
*
# static constructor(blockType, source, paramsopt)
Creates a new RezBlock.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
blockType |
string
|
The type of block ("block" or "card") |
||
source |
Object
|
The source element to render (e.g., a RezCard) |
||
params |
Object
|
<optional> |
{} | Additional parameters passed to the template |