Add method for theme: template.getJSContext

This commit is contained in:
Samy Pessé
2016-04-14 14:51:42 +02:00
parent e1e3d11932
commit 114c4abcd1
+14 -1
View File
@@ -216,11 +216,24 @@ WebsiteOutput.prototype.outputMultilingualIndex = function() {
// Render a template using nunjucks
// Templates are stored in `_layouts` folders
WebsiteOutput.prototype.render = function(tpl, context) {
var that = this;
var filename = this.templateName(tpl);
context = _.extend(context, {
template: {
self: filename
self: filename,
getJSContext: function() {
return {
page: _.omit(context.page, 'content'),
config: context.config,
file: context.file,
gitbook: context.gitbook,
basePath: location.normalize(that.resolveForPage(context.file.path, './')),
book: {
language: context.book.language
}
};
}
},
plugins: {