-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathindex.js
More file actions
33 lines (24 loc) · 753 Bytes
/
Copy pathindex.js
File metadata and controls
33 lines (24 loc) · 753 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
'use strict';
function addDeps(a, b){
if(a && a.cache && b){
if(b.cache){
a.cache.mergeDeps(b.cache);
}
a.cache.addDeps(b.realpath || b);
}
}
module.exports = function(content, file, conf) {
var fileReg = conf.reg || /<!--#include\svirtual="([^"]+)"\s*-->/gim;
content = content.replace(fileReg, function(ret, src) {
var path = file.getUrl(true, false).match(/(\/*\w+\/+)*/);
if (path) {
src = fis.project.getProjectPath() + '/' + path[0] + src;
if (fis.util.isFile(src)) {
var tpl = fis.file.wrap(src);
addDeps(file, tpl);
return tpl.getContent();
}
}
});
return content;
};