Class: TemplateRenderer

TemplateRenderer(capacityOrConfigopt)

Handles the rendering of HTML templates by resolving interpolation expressions. Uses an LruCache to cache parsed template AST segments with bounded capacity.

Constructor

new TemplateRenderer(capacityOrConfigopt)

Constructs the TemplateRenderer with a configurable LRU cache capacity.

Parameters:
Name Type Attributes Description
capacityOrConfig number | object <optional>

Maximum LRU cache capacity or configuration object.

Source:

Classes

TemplateRenderer

Members

cache :LruCache

LRU Cache storing parsed template AST segments.

Type:
Source:

capacity :number

Maximum capacity of the LRU cache.

Type:
  • number
Source:

Methods

clearCache()

Clears the template LRU cache.

Source:

parseTemplate(template) → {Array:.<TemplateSegment:>}

Parses a raw HTML template string into tokenized AST segments.

Parameters:
Name Type Description
template string

The HTML template string.

Source:
Returns:

Array of template segments.

Type
Array:.<TemplateSegment:>

render(template, resolveExpression) → {string}

Renders the template by replacing {{ expression }} and {{{ expression }}} with evaluated values.

Parameters:
Name Type Description
template string

The HTML template string.

resolveExpression function

Function to evaluate expressions.

Source:
Returns:

The rendered HTML string.

Type
string

resolveDynamicAttributes(html, resolveExpression) → {string}

Resolves dynamic attribute name binding syntax (:[attrName]="attrValue") in HTML string.

Parameters:
Name Type Description
html string

The HTML string.

resolveExpression function

Function to evaluate expressions.

Source:
Returns:

The HTML string with dynamic attributes resolved.

Type
string