mirror of
https://github.com/documentationjs/documentation.git
synced 2026-01-18 14:17:30 +00:00
Also: * Moves reduction out of parsers so that they don't have awkward function signatures
23 lines
610 B
JavaScript
23 lines
610 B
JavaScript
'use strict';
|
|
|
|
var fs = require('fs');
|
|
var path = require('path');
|
|
|
|
/**
|
|
* Get a Handlebars template file out of a theme and compile it into
|
|
* a template function
|
|
*
|
|
* @param {Object} Handlebars handlebars instance
|
|
* @param {string} themeModule base directory of themey
|
|
* @param {string} name template name
|
|
* @returns {Function} template function
|
|
*/
|
|
module.exports = function getTemplate(Handlebars, themeModule, name) {
|
|
try {
|
|
return Handlebars
|
|
.compile(fs.readFileSync(path.join(themeModule, name), 'utf8'));
|
|
} catch (e) {
|
|
throw new Error('Template file ' + name + ' missing');
|
|
}
|
|
};
|