performSubstitutions() function
Performs substitutions on an input string using Liquid.
Signature
export declare function performSubstitutions({ log, engine, input, substitutionsVariables, }: {
log: Logger;
engine: XpmLiquidEngine;
input: string;
substitutionsVariables: XpmLiquidSubstitutionsVariables;
}): Promise<string>;
Parameters
|
Parameter |
Type |
Description |
|---|---|---|
|
{ log, engine, input, substitutionsVariables, } |
{ log: Logger; engine: XpmLiquidEngine; input: string; substitutionsVariables: XpmLiquidSubstitutionsVariables; } |
Returns
Promise<string>
The fully substituted string.
Exceptions
XpmError If Liquid rendering fails.
Remarks
This function processes Liquid template syntax (variables and tags) by repeatedly rendering the input until no more substitutions are detected. The iterative approach supports nested substitutions where one property references another.
Processing workflow:
- Skip processing for empty strings to avoid unnecessary overhead.
- Prepare Liquid context with substitution variables.
- If
propertiesexist, wrap them inXpmLiquidPropertiesDropfor lazy evaluation and nested substitution support. - If
matrixparameters exist, wrap them inXpmLiquidMatrixDropfor template expansion variable access. - Iterate while Liquid syntax (
{{or{%) is present:- Parse and render the current string.
- Break if no changes occur (safety check).
- Continue with the substituted result.
- Return the fully substituted string.
The Drop pattern enables recursive property resolution: when a template accesses {{ properties.foo }} and foo contains {{ properties.bar }}, the next iteration resolves bar, and so on until no Liquid syntax remains.
Error handling:
Liquid rendering errors are caught, stripped of line number information (which can be misleading for nested templates), and re-thrown as XpmError.
Generated via tsdoc2docusaurus 1.3.0-pre by API Extractor/Documenter 7.55.2.