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. |
Classes
Members
cache :LruCache
LRU Cache storing parsed template AST segments.
Type:
capacity :number
Maximum capacity of the LRU cache.
Type:
- number
Methods
clearCache()
Clears the template LRU cache.
parseTemplate(template) → {Array:.<TemplateSegment:>}
Parses a raw HTML template string into tokenized AST segments.
Parameters:
| Name | Type | Description |
|---|---|---|
template |
string | The HTML template string. |
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. |
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. |
Returns:
The HTML string with dynamic attributes resolved.
- Type
- string