-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
34 lines (28 loc) · 1.31 KB
/
index.js
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
34
'use strict';
var HEAD_REG = /<!--FEATHER STATIC POSITION:HEAD-->|(<\/head>)/i, BOTTOM_REG = /<!--FEATHER STATIC POSITION:BOTTOM-->|(<\/body>)/i;
var TPL_DIR = __dirname + '/vendor/';
module.exports = function(ret){
var SUFFIX = feather.config.get('template.suffix');
var HEAD_TPL = feather.util.read(TPL_DIR + 'head.php').replace('#suffix#', SUFFIX);
var BOTTOM_TPL = feather.util.read(TPL_DIR + 'bottom.php').replace('#suffix#', SUFFIX);
if(feather.config.get('project.modulename') == 'common'){
var staticFile = feather.file.wrap(feather.project.getProjectPath() + '/_static_.' + SUFFIX);
staticFile.setContent(feather.util.read(TPL_DIR + 'static.php'));
ret.pkg[staticFile.subpath] = staticFile;
}
lothar.util.map(ret.ids, function(id, file){
if(file.isHtmlLike){
var content = file.getContent();
if(file.isPagelet){
content = HEAD_TPL + '\n' + content;
}else{
content = content.replace(HEAD_REG, function(all, tag){
return '\n' + HEAD_TPL + '\n' + (tag || '');
}).replace(BOTTOM_REG, function(all, tag){
return '\n' + BOTTOM_TPL + '\n' + (tag || '');
});
}
file.setContent(content);
}
});
};