Fix inclusion of block using a simple function

This commit is contained in:
Samy Pessé
2016-02-24 17:02:34 +01:00
parent 78e11bc6be
commit 1fa952b930
4 changed files with 12 additions and 4 deletions
+1 -1
View File
@@ -110,7 +110,7 @@ HTMLPipeline.prototype.transformCodeBlocks = function() {
return Promise(this.opts.onCodeBlock(source, lang))
.then(function(blk) {
if (blk.html !== true) {
if (blk.html === false) {
$code.text(blk.body);
} else {
$code.html(blk.body);
+1 -1
View File
@@ -282,7 +282,7 @@ BookPlugin.prototype.getBlocks = function() {
var that = this;
return _.mapValues(this.content.blocks || {}, function(block, blockName) {
block = _.isFunction(block)? { exec: block } : block;
block = _.isFunction(block)? { process: block } : block;
var fn = block.exec;
block.exec = function() {
+6 -1
View File
@@ -7,5 +7,10 @@ module.exports = {
// Highlight a code block
// This block can be replaced by plugins
code: _.identity
code: function(blk) {
return {
html: false,
body: blk.body
};
}
};
+4 -1
View File
@@ -146,12 +146,15 @@ TemplateEngine.prototype.addBlock = function(name, block) {
block = _.defaults(block || {}, {
shortcuts: [],
end: 'end'+name,
process: _.identity,
blocks: []
});
extName = blockExtName(name);
if (!block.process) {
throw new Error('Invalid block "' + name + '", it should have a "process" method');
}
if (this.hasBlock(name) && !defaultBlocks[name]) {
this.log.warn.ln('conflict in blocks, "'+name+'" is already defined');
}