mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-15 04:10:40 -07:00
refactor: filepath resolving into getTemplate
This commit is contained in:
@@ -75,12 +75,6 @@ var _engine = {
|
||||
handleCache: function(filepath) {
|
||||
if (!filepath) throw new Error('filepath cannot be null');
|
||||
|
||||
filepath = resolvePath(this.options.root, filepath);
|
||||
|
||||
if (!filepath.match(/\.\w+$/)) {
|
||||
filepath += this.options.extname;
|
||||
}
|
||||
|
||||
return this.getTemplate(filepath)
|
||||
.then((html) => {
|
||||
var tpl = this.options.cache && this.cache[filepath] || this.parse(html);
|
||||
@@ -88,6 +82,11 @@ var _engine = {
|
||||
});
|
||||
},
|
||||
getTemplate: function(filepath) {
|
||||
filepath = resolvePath(this.options.root, filepath);
|
||||
|
||||
if (!filepath.match(/\.\w+$/)) {
|
||||
filepath += this.options.extname;
|
||||
}
|
||||
return new Promise(function(resolve, reject) {
|
||||
fs.readFile(filepath, 'utf8', function(err, html) {
|
||||
err ? reject(err) : resolve(html);
|
||||
|
||||
Reference in New Issue
Block a user