mirror of
https://gitee.com/baidu/amis.git
synced 2024-11-30 02:58:05 +08:00
避免循环引用
This commit is contained in:
parent
47b24b5496
commit
ab1dc7d6fb
@ -1,8 +1,8 @@
|
||||
import {reigsterTplEnginer, filter} from './tpl';
|
||||
import moment from 'moment';
|
||||
import {PlainObject} from '../types';
|
||||
import isPlainObject from 'lodash/isPlainObject';
|
||||
import {createObject, isObject, setVariable, qsstringify} from './helper';
|
||||
import {Enginer} from './tpl';
|
||||
|
||||
const UNITS = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
|
||||
|
||||
@ -93,7 +93,7 @@ export const filterDate = (
|
||||
value = value.trim();
|
||||
}
|
||||
|
||||
value = filter(value, data);
|
||||
value = tokenize(value, data);
|
||||
|
||||
if (value && typeof value === 'string' && (m = relativeValueRe.exec(value))) {
|
||||
const date = new Date();
|
||||
@ -678,10 +678,11 @@ export function dataMapping(to: any, from: PlainObject): any {
|
||||
return ret;
|
||||
}
|
||||
|
||||
export function register() {
|
||||
reigsterTplEnginer('builtin', {
|
||||
test: str => !!~str.indexOf('$'),
|
||||
export function register(): Enginer & {name: string} {
|
||||
return {
|
||||
name: 'builtin',
|
||||
test: (str: string) => !!~str.indexOf('$'),
|
||||
compile: (str: string, data: object, defaultFilter = '| html') =>
|
||||
tokenize(str, data, defaultFilter)
|
||||
});
|
||||
};
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import {reigsterTplEnginer, filter} from './tpl';
|
||||
import {reigsterTplEnginer, filter, Enginer} from './tpl';
|
||||
import template from 'lodash/template';
|
||||
import {getFilters} from './tpl-builtin';
|
||||
import React from 'react';
|
||||
@ -47,9 +47,10 @@ function lodashCompile(str: string, data: object) {
|
||||
}
|
||||
}
|
||||
|
||||
export function register() {
|
||||
reigsterTplEnginer('lodash', {
|
||||
test: str => !!~str.indexOf('<%'),
|
||||
export function register(): Enginer & {name: string} {
|
||||
return {
|
||||
name: 'lodash',
|
||||
test: (str: string) => !!~str.indexOf('<%'),
|
||||
compile: (str: string, data: object) => lodashCompile(str, data)
|
||||
});
|
||||
};
|
||||
}
|
||||
|
@ -15,8 +15,6 @@ export function reigsterTplEnginer(name: string, enginer: Enginer) {
|
||||
enginers[name] = enginer;
|
||||
}
|
||||
|
||||
[registerBulitin, registerLodash].forEach(fn => fn());
|
||||
|
||||
export function filter(
|
||||
tpl?: string,
|
||||
data: object = {},
|
||||
@ -103,3 +101,12 @@ export function evalJS(js: string, data: object): any {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
[registerBulitin, registerLodash].forEach(fn => {
|
||||
const info = fn();
|
||||
|
||||
reigsterTplEnginer(info.name, {
|
||||
test: info.test,
|
||||
compile: info.compile
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user