init commit
This commit is contained in:
29
public/assets/libs/art-template/src/get.js
Normal file
29
public/assets/libs/art-template/src/get.js
Normal file
@@ -0,0 +1,29 @@
|
||||
/**
|
||||
* 获取编译缓存(可由外部重写此方法)
|
||||
* @param {String} 模板名
|
||||
* @param {Function} 编译好的函数
|
||||
*/
|
||||
template.get = function (filename) {
|
||||
|
||||
var cache;
|
||||
|
||||
if (cacheStore[filename]) {
|
||||
// 使用内存缓存
|
||||
cache = cacheStore[filename];
|
||||
} else if (typeof document === 'object') {
|
||||
// 加载模板并编译
|
||||
var elem = document.getElementById(filename);
|
||||
|
||||
if (elem) {
|
||||
var source = (elem.value || elem.innerHTML)
|
||||
.replace(/^\s*|\s*$/g, '');
|
||||
cache = compile(source, {
|
||||
filename: filename
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return cache;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user