1 | export interface ITokens {
|
2 | /** An array of constant strings */
|
3 | readonly strings: string[];
|
4 | /** An array of variable names */
|
5 | readonly varNames: string[];
|
6 | }
|
7 | /**
|
8 | * Declares the open and close tag respectively
|
9 | */
|
10 | export declare type ITags = [string, string];
|
11 | /**
|
12 | * The options that goes to the tokenization algorithm
|
13 | */
|
14 | export interface ITokenizeOptions {
|
15 | /**
|
16 | * Maximum allowed variable name. Set this to a safe value to prevent a bad template from blocking
|
17 | * the tokenization unnecessarily
|
18 | */
|
19 | maxVarNameLength?: number;
|
20 | /**
|
21 | * The string symbols that mark the opening and closing of a variable name in
|
22 | * the template.
|
23 | * It defaults to `['{{', '}}']`
|
24 | */
|
25 | tags?: ITags;
|
26 | }
|
27 | /**
|
28 | * Parses a template and returns the tokens in an object.
|
29 | *
|
30 | * @throws `TypeError` if there's an issue with its inputs
|
31 | * @throws `SyntaxError` if there's an issue with the template
|
32 | *
|
33 | * @param template the template
|
34 | * @param openSym the string that marks the start of a variable name
|
35 | * @param closeSym the string that marks the start of a variable name
|
36 | * @returns the resulting tokens as an object that has strings and variable names
|
37 | */
|
38 | export declare function tokenize(template: string, options?: ITokenizeOptions): ITokens;
|