Class

RezBlock

RezBlock()

Constructor

# 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

View Source rez_view.js, line 64

Members

string

# blockType

The type of this block ("block" or "card").

View Source rez_view.js, line 130

boolean

# flipped

Whether this block is showing its flipped (back) side.

View Source rez_view.js, line 154

Object

# params

Additional parameters passed to the template.

View Source rez_view.js, line 166

RezBlock | null

# parentBlock

The parent block in the view hierarchy.

View Source rez_view.js, line 118

Object

# source

The source element being rendered.

View Source rez_view.js, line 142

Methods

# bindBlocks() → {Object}

Renders all nested blocks to HTML.

View Source rez_view.js, line 399

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 block
  • params: The params object
  • source: The source element
  • Source's bindAs name: The source element (aliased)

View Source rez_view.js, line 360

Complete bindings object for template rendering

Object

# bindings() → {Object}

Computes complete bindings including values and rendered blocks.

View Source rez_view.js, line 430

Complete bindings object

Object

# copy() → {RezBlock}

Creates a copy of this block.

View Source rez_view.js, line 492

A new block with the same properties

RezBlock

# css_classes() → {string}

Gets the CSS classes for this block's wrapper element.

View Source rez_view.js, line 456

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

View Source rez_view.js, line 311

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

View Source rez_view.js, line 279

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

View Source rez_view.js, line 328

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.

View Source rez_view.js, line 380

Map of binding names to RezBlock instances

Object

# getViewTemplate() → {function}

Gets the view template function for this block.

View Source rez_view.js, line 408

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.

View Source rez_view.js, line 477

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

View Source rez_view.js, line 218

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

View Source rez_view.js, line 204

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

View Source rez_view.js, line 180

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

View Source rez_view.js, line 229

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

View Source rez_view.js, line 192

The attribute value

*

# parentBindings() → {Object}

Gets bindings from the parent block, if any.

View Source rez_view.js, line 417

Parent bindings or empty object

Object

# renderBlock() → {string}

Renders the block content using its template and bindings.

View Source rez_view.js, line 444

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

View Source rez_view.js, line 247

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

View Source rez_view.js, line 97