@mtime()
This commit is contained in:
parent
218a925599
commit
79db8108ea
|
@ -80,6 +80,8 @@ export default class {
|
||||||
.replace(/@js/g, "`);") // inject bare javascript
|
.replace(/@js/g, "`);") // inject bare javascript
|
||||||
.replace(/@endjs/g, ";__html.push(`")
|
.replace(/@endjs/g, ";__html.push(`")
|
||||||
|
|
||||||
|
.replace(/@mtime\((.*?)\)/g, `\`);__html.push(this.getMtime('$1'));__html.push(\``)
|
||||||
|
|
||||||
.replace(/@include\((.*?)\)/g, (_, inc) => this.render(inc, data)) // include template
|
.replace(/@include\((.*?)\)/g, (_, inc) => this.render(inc, data)) // include template
|
||||||
|
|
||||||
.replace(/@for\((.*?)\)$/gm, `\`);for($1){__html.push(\``)
|
.replace(/@for\((.*?)\)$/gm, `\`);for($1){__html.push(\``)
|
||||||
|
@ -96,7 +98,8 @@ export default class {
|
||||||
|
|
||||||
return (new Function("_data", code)).bind({
|
return (new Function("_data", code)).bind({
|
||||||
escape: this.escape,
|
escape: this.escape,
|
||||||
forEach: this.forEach
|
forEach: this.forEach,
|
||||||
|
getMtime: this.getMtime
|
||||||
})(data);
|
})(data);
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
console.log(file, err.message);
|
console.log(file, err.message);
|
||||||
|
@ -124,4 +127,13 @@ export default class {
|
||||||
else
|
else
|
||||||
throw new Error(`${o} is not a iterable object`);
|
throw new Error(`${o} is not a iterable object`);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
getMtime(file) {
|
||||||
|
try {
|
||||||
|
return +(fs.statSync(path.normalize(process.cwd() + file)).mtimeMs + '').split(".")[0];
|
||||||
|
} catch(err) {
|
||||||
|
console.log(err);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue
Block a user