diff options
Diffstat (limited to 'lib/templating/render.js')
-rw-r--r-- | lib/templating/render.js | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/lib/templating/render.js b/lib/templating/render.js index 22c0dc4..584890a 100644 --- a/lib/templating/render.js +++ b/lib/templating/render.js @@ -1,6 +1,6 @@ var Promise = require('../utils/promise'); var timing = require('../utils/timing'); - +var TemplateOutput = require('../models/templateOutput'); var replaceShortcuts = require('./replaceShortcuts'); /** @@ -10,16 +10,23 @@ var replaceShortcuts = require('./replaceShortcuts'); @param {String} filePath @param {String} content @param {Object} context - @return {Promise<String>} + @return {Promise<TemplateOutput>} */ function renderTemplate(engine, filePath, content, context) { context = context || {}; - var env = engine.toNunjucks(); + // Mutable objects to contains all blocks requiring post-processing + var blocks = {}; + + // Create nunjucks environment + var env = engine.toNunjucks(blocks); + + // Replace shortcuts from plugin's blocks content = replaceShortcuts(engine, filePath, content); return timing.measure( 'template.render', + Promise.nfcall( env.renderString.bind(env), content, @@ -28,6 +35,9 @@ function renderTemplate(engine, filePath, content, context) { path: filePath } ) + .then(function(content) { + return TemplateOutput.create(content, blocks); + }) ); } |