Skip to content

Commit

Permalink
log err
Browse files Browse the repository at this point in the history
  • Loading branch information
1v9 committed Oct 15, 2019
1 parent b3e40f7 commit c831fe2
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions scripts/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function njkCompile(data) {
const templateDir = path.dirname(data.path);
const config = Object.assign({
autoescape: false,
watch: false
watch : false
}, hexo.config.nunjucks);
const env = nunjucks.configure(templateDir, config);
return nunjucks.compile(data.text, env, data.path);
Expand All @@ -24,9 +24,16 @@ njkRenderer.compile = function(data) {
const compiledTemplate = njkCompile(data);
// Need a closure to keep the compiled template.
return function(locals, callback) {
return compiledTemplate.render(locals, callback);
}
}
return new Promise(resolve => {
compiledTemplate.render(locals, callback, (err, result) => {
if (err) {
hexo.log.error(err);
}
resolve(result);
});
});
};
};

hexo.extend.renderer.register('njk', 'html', njkRenderer);
hexo.extend.renderer.register('swig', 'html', njkRenderer);

0 comments on commit c831fe2

Please sign in to comment.