Tagscript

ValidateTags

TagScript


Function: validateTags()

validateTags(message, tags): UnknownTag[]

Defined in: packages/tagscript/src/lib/manifest.ts:128

Reports every tag in a template that the given manifest does not define.

A tag nothing handles is not an error at render time. The interpreter leaves it in the output exactly as written, braces included, and records nothing, so a mistyped tag reaches whoever reads the output and nobody finds out. Run this where the template is written instead, and the person who made the typo is the one who hears about it.

Parameters

message

string

The template to check.

tags

readonly TagDefinition[]

Every tag that is allowed to appear.

Returns

UnknownTag[]

The offending tags, in document order.

Example

validateTags('Hi {naem}', [{ name: 'name', label: 'Name' }]);
// [{ declaration: 'naem', start: 3, end: 8 }]

On this page