mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-21 01:53:26 +00:00
Add test for file variables in templating
This commit is contained in:
@@ -173,6 +173,11 @@ Page.prototype.toHTML = function(output) {
|
||||
|
||||
return pipeline.output()
|
||||
.then(that.update);
|
||||
})
|
||||
|
||||
// Return content itself
|
||||
.then(function() {
|
||||
return that.content;
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
+3
-1
@@ -5,13 +5,15 @@ require('./readme');
|
||||
require('./summary');
|
||||
require('./glossary');
|
||||
require('./langs');
|
||||
require('./page');
|
||||
require('./parse');
|
||||
|
||||
require('./git');
|
||||
require('./template');
|
||||
require('./conrefs');
|
||||
|
||||
// Page and HTML generation
|
||||
require('./page');
|
||||
|
||||
// Output
|
||||
require('./output-json');
|
||||
require('./assets-inliner');
|
||||
|
||||
+19
-1
@@ -8,7 +8,9 @@ describe('Page', function() {
|
||||
return mock.setupDefaultBook({
|
||||
'heading.md': '# Hello\n\n## World',
|
||||
'links.md': '[link](hello.md) [readme](README.md)',
|
||||
'folder/paths.md': ''
|
||||
'folder/paths.md': '',
|
||||
'variables/file/mtime.md': '{{ file.mtime }}',
|
||||
'variables/file/path.md': '{{ file.path }}'
|
||||
})
|
||||
.then(function(_book) {
|
||||
book = _book;
|
||||
@@ -93,4 +95,20 @@ describe('Page', function() {
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
describe('Templating Context', function() {
|
||||
it('should set file.mtime', function() {
|
||||
var page = book.addPage('variables/file/mtime.md');
|
||||
return page.toHTML(output)
|
||||
.then(function(content) {
|
||||
content.should.endWith('(CET)</p>\n');
|
||||
});
|
||||
});
|
||||
|
||||
it('should set file.[path]', function() {
|
||||
var page = book.addPage('variables/file/path.md');
|
||||
return page.toHTML(output)
|
||||
.should.be.fulfilledWith('<p>variables/file/path.md</p>\n');
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user