diff options
author | Samy Pesse <samypesse@gmail.com> | 2016-05-04 19:01:31 +0200 |
---|---|---|
committer | Samy Pesse <samypesse@gmail.com> | 2016-05-04 19:01:31 +0200 |
commit | c4b54033cefe54f2c7fda92b8765ed500178ea74 (patch) | |
tree | 14b83ff6b7950f542dfff4dfa9c6c676209631bb /lib/models/templateBlock.js | |
parent | 4d85d6eb6e12192146e8f2450f1bddada6e6f6d1 (diff) | |
download | gitbook-c4b54033cefe54f2c7fda92b8765ed500178ea74.zip gitbook-c4b54033cefe54f2c7fda92b8765ed500178ea74.tar.gz gitbook-c4b54033cefe54f2c7fda92b8765ed500178ea74.tar.bz2 |
Fix #1268: fix shortcuts of template block not being applied
Diffstat (limited to 'lib/models/templateBlock.js')
-rw-r--r-- | lib/models/templateBlock.js | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/lib/models/templateBlock.js b/lib/models/templateBlock.js index 340f808..76aeb55 100644 --- a/lib/models/templateBlock.js +++ b/lib/models/templateBlock.js @@ -4,6 +4,7 @@ var Immutable = require('immutable'); var Promise = require('../utils/promise'); var genKey = require('../utils/genKey'); +var TemplateShortcut = require('./templateShortcut'); var NODE_ENDARGS = '%%endargs%%'; @@ -23,7 +24,7 @@ var TemplateBlock = Immutable.Record({ blocks: Immutable.List(), // List of shortcuts to replace with this block - shortcuts: Immutable.List(), + shortcuts: Immutable.Map(), // Function to execute in post processing post: null, @@ -55,8 +56,19 @@ TemplateBlock.prototype.getBlocks = function() { return this.get('blocks'); }; + +/** + Return shortcuts associated with this block or undefined + + @return {TemplateShortcut|undefined} +*/ TemplateBlock.prototype.getShortcuts = function() { - return this.get('shortcuts'); + var shortcuts = this.get('shortcuts'); + if (shortcuts.size === 0) { + return undefined; + } + + return TemplateShortcut.createForBlock(this, shortcuts); }; /** @@ -292,7 +304,10 @@ TemplateBlock.create = function(blockName, block) { }); } - block = block.set('name', blockName); + block = block.merge({ + name: blockName + }); + return new TemplateBlock(block); }; |