MCPcopy
hub / github.com/baidu/amis / tokenize

Function tokenize

packages/amis-core/src/utils/tokenize.ts:14–38  ·  view source on GitHub ↗
(
  str: string,
  data: object,
  defaultFilter: string = '| html'
)

Source from the content-addressed store, hash-verified

12}
13
14export const tokenize = (
15 str: string,
16 data: object,
17 defaultFilter: string = '| html'
18) => {
19 if (!str || typeof str !== 'string') {
20 return str;
21 }
22
23 try {
24 const ast = memoParse(str, {
25 evalMode: false,
26 allowFilter: true
27 });
28
29 const result = new Evaluator(data, {
30 defaultFilter
31 }).evalute(ast);
32
33 return `${result == null ? '' : result}`;
34 } catch (e) {
35 console.warn(e);
36 return str;
37 }
38};

Callers 10

componentDidMountMethod · 0.90
registerFunction · 0.90
resolveMappingFunction · 0.90
filterClassNameObjectFunction · 0.90
constructorMethod · 0.90
componentDidMountMethod · 0.90
evalTrackExpressionFunction · 0.70
isApiOutdatedFunction · 0.70
componentDidUpdateMethod · 0.50
tokenize.test.tsFile · 0.50

Calls 2

memoParseFunction · 0.85
evaluteMethod · 0.80

Tested by

no test coverage detected