summaryrefslogtreecommitdiffstats
path: root/lib/models/templateBlock.js
diff options
context:
space:
mode:
authorSamy Pessé <samypesse@gmail.com>2016-04-25 11:58:55 +0200
committerSamy Pessé <samypesse@gmail.com>2016-04-25 11:58:55 +0200
commitf6e123f1ed36019a2ec5da1f97b27d22352b689a (patch)
tree326670b5cf1ff0cbdfbcd35d53f12fb858f874b2 /lib/models/templateBlock.js
parente1e4e7f01177d968e63f0b3a1830eda1adacb56b (diff)
downloadgitbook-f6e123f1ed36019a2ec5da1f97b27d22352b689a.zip
gitbook-f6e123f1ed36019a2ec5da1f97b27d22352b689a.tar.gz
gitbook-f6e123f1ed36019a2ec5da1f97b27d22352b689a.tar.bz2
Add base rendering for template
Diffstat (limited to 'lib/models/templateBlock.js')
-rw-r--r--lib/models/templateBlock.js20
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