diff options
Diffstat (limited to 'lib/models/templateBlock.js')
-rw-r--r-- | lib/models/templateBlock.js | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/lib/models/templateBlock.js b/lib/models/templateBlock.js index ec7dc7c..cce636e 100644 --- a/lib/models/templateBlock.js +++ b/lib/models/templateBlock.js @@ -16,7 +16,7 @@ var TemplateBlock = Immutable.Record({ shortcuts: Immutable.List(), post: null, parse: true -}); +}, 'TemplateBlock'); TemplateBlock.prototype.getName = function() { return this.get('name'); @@ -251,6 +251,24 @@ TemplateBlock.indexBlockResult = function(blk) { }; /** + Create a template block from a function or an object + + @param {String} blockName + @param {Object} block + @return {TemplateBlock} +*/ +TemplateBlock.create = function(blockName, block) { + if (is.fn(block)) { + block = new Immutable.Map({ + process: block + }); + } + + block = block.set('name', blockName); + return new TemplateBlock(block); +}; + +/** Extract kwargs from an arguments array @param {Array} args |