import type { FormatterRegistry } from './formatters'; export type TemplateContext = { locale: string; formatters: FormatterRegistry; onUnknownFormatter?: (name: string) => void; }; /** * Tokens emitted by `tokenize()` for slot-aware rendering (e.g. Vue's * `` component). * * - `text`: literal substring between placeholders. * - `var`: `{{name}}` or `{{name, modifier(opts)}}`. The orchestrator * replaces these with `data[name]` (optionally piped through * a formatter); slot renderers do the same. * - `slot`: `{slot-name}` (single curly braces). Slot renderers fill * these from a named scoped slot; plain `template()` leaves * them as literal text (no slot-aware substitution). */ export type TextToken = { kind: 'text'; value: string; }; export type VarToken = { kind: 'var'; name: string; modifierExpression?: string; }; export type SlotToken = { kind: 'slot'; name: string; }; export type TemplateToken = TextToken | VarToken | SlotToken; /** * Parse `str` into an interleaved sequence of text / var / slot tokens. * * Designed for renderers that produce VNodes (or other non-string * structures): the plain `template()` function still returns a string * for the common case. */ export declare function tokenize(str: string): TemplateToken[]; /** * Substitute `{{var}}` placeholders. With a `TemplateContext`, also supports * modifier syntax: `{{var, modifier}}` and `{{var, modifier(opts)}}`. * * - Unknown data key → placeholder left in place (unchanged from prior behaviour). * - Unknown modifier → raw value substituted, `onUnknownFormatter` invoked. * - Malformed modifier expression (e.g. unbalanced parens) → raw value substituted. * * The third parameter accepts either a `TemplateContext` (modern, with * formatter support) or a `RegExp` (legacy escape-hatch for custom * placeholder delimiters). Passing a `RegExp` disables modifier dispatch, * matching the pre-formatter behaviour for callers that supplied their own * delimiter. */ export declare function template(str: string, data: Record, ctxOrRegex?: TemplateContext | RegExp): string;