Step 2: Implementation
Implement the custom tokens
Use the defineToken
function to implement the tokens. This function takes the name of the token and its implementation and returns the implemented token.
Constant tokens
Implement the
constant
functionthis
in the function is aRegExpToken
that contains the expression preceding the custom tokenThe token can append to, wrap around, or modify
this
in any way
Dynamic tokens
Implement the
dynamic
functionthis
in the function is aRegExpToken
that contains the expression preceding the custom tokenToken arguments are passed to the
dynamic
function as argumentsTemplate string arguments are converted to ordinary strings automatically
Mixed tokens
Implement both the
constant
anddynamic
functionsSame rules apply for both functions
If the custom token is called, the
dynamic
function will handle the call. Otherwise, theconstant
function will be used.
Last updated