'use strict' const Promise = require('bluebird') const dust = require('dustjs-linkedin') dust.renderPromise = Promise.promisify(dust.render, { context: dust }) module.exports = async function (template, master) { const locals = Object.assign({}, this.app.locals, this.locals) console.log(locals) let html if (this.cache) { html = this.cache.html } if (!html && template) { html = await dust.renderPromise(template, locals) } // always render master, since shim mw will add // scripts depending on user agent string if (typeof master === 'function') { html = master(Object.assign({ html }, locals)) } this.send(html) }