diff options
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); }; |