mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-16 23:55:20 +00:00
28 lines
603 B
JavaScript
28 lines
603 B
JavaScript
var Promise = require('../utils/promise');
|
|
|
|
var replaceShortcuts = require('./replaceShortcuts');
|
|
|
|
/**
|
|
Render a template
|
|
|
|
@param {TemplateEngine} engine
|
|
@param {String} filePath
|
|
@param {String} content
|
|
@param {Object} ctx
|
|
@return {Promise<String>}
|
|
*/
|
|
function renderTemplateFile(engine, filePath, content, context) {
|
|
context = context || {};
|
|
var env = engine.toNunjucks();
|
|
|
|
content = replaceShortcuts(engine, filePath, content);
|
|
|
|
return Promise.nfcall(
|
|
env.render.bind(env),
|
|
content,
|
|
context
|
|
);
|
|
}
|
|
|
|
module.exports = renderTemplateFile;
|