forked from p96170835/amis
优化 tpl 引入方式
This commit is contained in:
parent
3d6a6160f3
commit
4d81135021
|
@ -14,8 +14,6 @@ import {
|
|||
} from './factory';
|
||||
import {wrapFetcher, buildApi} from './utils/api';
|
||||
import {filter, reigsterTplEnginer, evalExpression} from './utils/tpl';
|
||||
import './utils/tpl-builtin';
|
||||
import './utils/tpl-lodash';
|
||||
import * as utils from './utils/helper';
|
||||
import {resizeSensor} from './utils/resize-sensor';
|
||||
import {setIconVendor} from './renderers/Form/IconPickerIcons';
|
||||
|
|
|
@ -563,8 +563,10 @@ export function dataMapping(to: any, from: PlainObject): any {
|
|||
return ret;
|
||||
}
|
||||
|
||||
reigsterTplEnginer('builtin', {
|
||||
test: str => !!~str.indexOf('$'),
|
||||
compile: (str: string, data: object, defaultFilter = '| html') =>
|
||||
tokenize(str, data, defaultFilter)
|
||||
});
|
||||
export function register() {
|
||||
reigsterTplEnginer('builtin', {
|
||||
test: str => !!~str.indexOf('$'),
|
||||
compile: (str: string, data: object, defaultFilter = '| html') =>
|
||||
tokenize(str, data, defaultFilter)
|
||||
});
|
||||
}
|
||||
|
|
|
@ -47,7 +47,9 @@ function lodashCompile(str: string, data: object) {
|
|||
}
|
||||
}
|
||||
|
||||
reigsterTplEnginer('lodash', {
|
||||
test: str => !!~str.indexOf('<%'),
|
||||
compile: (str: string, data: object) => lodashCompile(str, data)
|
||||
});
|
||||
export function register() {
|
||||
reigsterTplEnginer('lodash', {
|
||||
test: str => !!~str.indexOf('<%'),
|
||||
compile: (str: string, data: object) => lodashCompile(str, data)
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import {createObject} from './helper';
|
||||
import {getFilters} from './tpl-builtin';
|
||||
import {register as registerBulitin, getFilters} from './tpl-builtin';
|
||||
import {register as registerLodash} from './tpl-lodash';
|
||||
|
||||
export interface Enginer {
|
||||
test: (tpl: string) => boolean;
|
||||
|
@ -74,3 +75,5 @@ export function evalJS(js: string, data: object): any {
|
|||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
[registerBulitin, registerLodash].forEach(fn => fn());
|
||||
|
|
Loading…
Reference in New Issue