Skip to main content

TemplateExpander class

A generic template expansion engine for matrix-based template processing.

Signature

export declare class TemplateExpander<TTemplate, TInstance>

Remarks

This class provides shared functionality for expanding template names and creating multiple instances from a single template definition with matrix parameters. It eliminates code duplication between Actions and BuildConfigurations classes by extracting the common template expansion logic.

Template expansion process:

  1. Matrix processing: Validates matrix structure and performs Liquid substitutions on matrix values.
  2. Combination generation: Computes the Cartesian product of all matrix parameter values.
  3. Name expansion: For each combination, substitutes matrix values into the template name.
  4. Instance creation: Invokes the factory callback to create instances with expanded names and matrix parameters.

The class is generic to support different template and instance types whilst maintaining type safety throughout the expansion process.

Constructors

Constructor

Modifiers

Description

(constructor)({ engine, substitutionsVariables, log, }, input)

Constructs a template expander instance.

Properties

Property

Modifiers

Type

Description

engine

readonly

LiquidEngine

The Liquid templating engine for variable substitution.

log

readonly

Logger

The logger instance for output and diagnostics.

substitutionsVariables

readonly

LiquidSubstitutionsVariables

The variables available for substitution in templates.

Methods

Method

Modifiers

Description

_expandName({ templateName, combination, templateType, }, input)

protected

Expands a template name with matrix parameter substitutions.

expandTemplate({ templateName, matrix, templateContent, templateType, instanceFactory, }, input)

Expands a template into multiple instances based on matrix parameters.


Generated via tsdoc2docusaurus 1.3.2 by API Extractor/Documenter 7.57.2.