mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-16 15:45:13 +00:00
Add method for theme: template.getJSContext
This commit is contained in:
+14
-1
@@ -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: {
|
||||
|
||||
Reference in New Issue
Block a user