cover all

This commit is contained in:
harttle
2017-08-14 22:07:08 +08:00
parent 7904f823a8
commit 72597c52e5
14 changed files with 268 additions and 205 deletions
+3 -8
View File
@@ -43,15 +43,10 @@ var _engine = {
return this.renderer.renderTemplates(tpl, scope)
},
parseAndRender: function (html, ctx, opts) {
console.log('parse and render')
return Promise.resolve()
.then(() => this.parse(html))
.then(tpl => this.render(tpl, ctx, opts))
.catch(e => {
if (e instanceof Errors.RenderBreakError) {
return e.html
}
throw e
})
},
renderFile: function (filepath, ctx, opts) {
opts = _.assign({}, opts)
@@ -93,8 +88,8 @@ var _engine = {
return Promise.resolve(tpl)
}
return readFileAsync(filepath)
.then(str => this.parse(str))
.then(tpl => (this.cache[filepath] = tpl))
.then(str => this.parse(str))
.then(tpl => (this.cache[filepath] = tpl))
} else {
return readFileAsync(filepath).then(str => this.parse(str, filepath))
}