From 32f52f2d955ffa0080ad366910567962d178d78b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samy=20Pess=C3=A9?= Date: Thu, 25 Feb 2016 14:26:27 +0100 Subject: [PATCH] Call page hooks during transformation to HTML --- lib/page/index.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lib/page/index.js b/lib/page/index.js index 57b048d6e..e8c4de72c 100644 --- a/lib/page/index.js +++ b/lib/page/index.js @@ -142,8 +142,19 @@ Page.prototype.toHTML = function(output) { this.log.debug.ln('start parsing file', this.path); + function hook(name) { + return output.plugins.hook(name, that.getContext().page) + .then(function(result) { + if(result) that.update(result.content); + }); + } + return this.read() + .then(function() { + return hook('page:before'); + }) + // Pre-process page with parser .then(function() { return that.parser.page.prepare(that.content) @@ -198,6 +209,10 @@ Page.prototype.toHTML = function(output) { .then(that.update); }) + .then(function() { + return hook('page'); + }) + // Return content itself .then(function() { return that.content;