Skip to content

Commit

Permalink
Execute 'after_render' filter when rendering with precompiled renderer
Browse files Browse the repository at this point in the history
  • Loading branch information
akfish committed Mar 1, 2016
1 parent abf23ab commit 95fb3ce
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions lib/theme/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,24 @@ View.prototype._resolveLayout = function(name) {

View.prototype._precompile = function() {
var render = this._render;
var renderer = render.getRenderer(pathFn.extname(this.path));
var ctx = render.context;
var ext = pathFn.extname(this.path);
var renderer = render.getRenderer(ext);
var data = {
path: this.source,
text: this.data._content
};

if (typeof renderer.compile === 'function') {
var compiled = this._compiledSync = renderer.compile(data);
this._compiled = Promise.method(compiled);
this._compiled = Promise.method(function(locals) {
var result = compiled(locals);
var output = render.getOutput(ext) || ext;
return ctx.execFilter('after_render:' + output, result, {
context: ctx,
args: [data]
});
});
} else {
this._compiledSync = function(locals) {
return render.renderSync(data, locals);
Expand Down

0 comments on commit 95fb3ce

Please sign in to comment.