mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-24 03:16:40 +00:00
Improve tests on blocks extensions
This commit is contained in:
@@ -169,6 +169,7 @@ TemplateEngine.prototype.addBlock = function(name, block) {
|
||||
body: args.pop()()
|
||||
};
|
||||
})
|
||||
.reverse()
|
||||
.value();
|
||||
|
||||
var body = args.pop();
|
||||
|
||||
@@ -117,5 +117,15 @@ describe('Plugins', function () {
|
||||
done
|
||||
);
|
||||
});
|
||||
|
||||
it('should correctly extend template blocks with different sub-blocks', function(done) {
|
||||
qdone(
|
||||
books[0].template.renderString('{% test4join separator=";" %}hello{% also %}the{% finally %}world{% endtest4join %}')
|
||||
.then(function(content) {
|
||||
assert.equal(content, "hello;the;world");
|
||||
}),
|
||||
done
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
var assert = require("assert");
|
||||
|
||||
module.exports = {
|
||||
blocks: {
|
||||
"test": {
|
||||
@@ -18,6 +20,17 @@ module.exports = {
|
||||
process: function(blk) {
|
||||
return [blk.body, blk.blocks[0].body].join(blk.kwargs.separator);
|
||||
}
|
||||
},
|
||||
"test4join": {
|
||||
blocks: [
|
||||
"also", "finally"
|
||||
],
|
||||
process: function(blk) {
|
||||
assert(blk.blocks.length, 2);
|
||||
assert(blk.blocks[0].name, "also");
|
||||
assert(blk.blocks[1].name, "finally");
|
||||
return [blk.body, blk.blocks[0].body, blk.blocks[1].body].join(blk.kwargs.separator);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user