Token Class
Represents a special or lazily-evaluated value.
Can be used to delay evaluation of a certain value in case, for example, that it requires some context or late-bound data. Can also be used to mark values that need special processing at document rendering time.
Tokens can be embedded into strings while retaining their original semantics.
| Source | core/lib/token.ts |
|---|---|
| Type last changed |
Methods
asAny(value: any): IResolvable@staticmethod def as_any(value: Any) -> IResolvablepublic static IResolvable asAny(Object value)public static IResolvable AsAny(object value)func AsAny(Value interface{}) IResolvable static #asList(value: any, options?: EncodingOptions): string[]@staticmethod def as_list(value: Any, options: typing.Optional[EncodingOptions] = None) -> typing.List[str]public static List<String> asList(Object value, EncodingOptions options)public static string[] AsList(object value, EncodingOptions? options = null)func AsList(Value interface{}, Options EncodingOptions) *[]*string static #asNumber(value: any): number@staticmethod def as_number(value: Any) -> int | floatpublic static Number asNumber(Object value)public static double AsNumber(object value)func AsNumber(Value interface{}) *float64 static #asString(value: any, options?: EncodingOptions): string@staticmethod def as_string(value: Any, options: typing.Optional[EncodingOptions] = None) -> strpublic static String asString(Object value, EncodingOptions options)public static string AsString(object value, EncodingOptions? options = null)func AsString(Value interface{}, Options EncodingOptions) *string static #notes
If the Token is initialized with a literal, the stringified value of the literal is returned. Otherwise, a special quoted string representation of the Token is returned that can be embedded into other strings.
Strings with quoted Tokens in them can be restored back into complex values with the Tokens restored by calling resolve() on the string.
compareStrings(possibleToken1: string, possibleToken2: string): TokenComparison@staticmethod def compare_strings(possible_token1: str, possible_token2: str) -> TokenComparisonpublic static TokenComparison compareStrings(String possibleToken1, String possibleToken2)public static TokenComparison CompareStrings(string possibleToken1, string possibleToken2)func CompareStrings(PossibleToken1 *string, PossibleToken2 *string) TokenComparison static #isResolved(obj: any): boolean@staticmethod def is_resolved(obj: Any) -> boolpublic static Boolean isResolved(Object obj)public static bool IsResolved(object obj)func IsResolved(Obj interface{}) *bool static #1 parameter
Parameters
objobjobjobjObj— The object to test.
isUnresolved(obj: any): boolean@staticmethod def is_unresolved(obj: Any) -> boolpublic static Boolean isUnresolved(Object obj)public static bool IsUnresolved(object obj)func IsUnresolved(Obj interface{}) *bool static #notes · 1 parameter
One of these must be true:
objis an IResolvableobjis a string containing at least one encodedIResolvableobjis either an encoded number or list
This does NOT recurse into lists or objects to see if they contain resolvables.
Parameters
objobjobjobjObj— The object to test.