# @isdk/match-ex-template

> Template interpolation plugin for @isdk/match-ex, backed by @isdk/template-engines. Importing it registers StringTemplate into the engine, so {{placeholder}} expectations interpolate out of the box.

Latest version **0.1.2** (published 2026-09-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install @isdk/match-ex-template
pnpm add @isdk/match-ex-template
yarn add @isdk/match-ex-template
bun add @isdk/match-ex-template
```

## Health

**Score 70/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; recently updated; high maintenance score; high quality score.

Warnings: low downloads; pre 1.0.

## Facts

| | |
|---|---|
| Version | 0.1.2 |
| Published | 2026-09-17 |
| First published | 2026-09-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 5.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Riceball LEE <snowyu.lee@gmail.com> |
| Maintainers | isdk |
| Keywords | match-ex, template, interpolation, plugin, isdk |

## Links

- npm: https://www.npmjs.com/package/@isdk/match-ex-template
- Repository: https://github.com/isdk/match-ex-template.js
- Issues: https://github.com/isdk/match-ex-template.js/issues
- npm.io page: https://npm.io/package/@isdk/match-ex-template

## Dependencies (1)

- [@isdk/template-engines](https://npm.io/package/@isdk/template-engines.md) ^0.6.11

## Recent versions

- 0.1.2 (latest) — 2026-09-17
- 0.1.1 — 2026-09-17

## README

# @isdk/match-ex-template

> 【English|[中文](./README.cn.md)】
---

Template interpolation plugin for [`@isdk/match-ex`](https://github.com/isdk/match-ex.js), backed by [`@isdk/template-engines`](https://github.com/isdk/template-engines.js).

Importing this package registers `StringTemplate` into the engine, so `{{placeholder}}` expectations interpolate out of the box.

## What it enables

- `{{name}}` placeholders inside expected strings, regex sources and nested objects — resolved against `ValidationContext.data`.
- Pure-placeholder replacement: `{{user}}` resolves to the original object (not its stringification), enabling deep object matching.
- Recursive resolution: templates inside resolved values keep interpolating.

## Usage

```ts
import { validate, ValidationContext } from '@isdk/match-ex'
import '@isdk/match-ex-template'

const ctx = new ValidationContext({ data: { name: 'Alice' } })

await validate('Hello Alice!', 'Hello {{name}}!', ctx)

// Regex + template
await validate('Hello Alice!', /{{name}}/i, ctx)

// Pure placeholder → object
await validate(
  { id: 1, name: 'Alice' },
  '{{user}}', // resolved to { id: 1, name: 'Alice' } if ctx.data.user is that object
  ctx
)
```

## Exports

| Export | Description |
|---|---|
| `StringTemplate` | Re-exported from `@isdk/template-engines` for convenience. |

Use a different dialect? Call `setStringTemplate(impl)` from `@isdk/match-ex` with your own `{ formatIf(options) }` implementation instead.

## License

MIT © Riceball Lee

---
_Source: https://npm.io/package/@isdk/match-ex-template · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
