summaryrefslogtreecommitdiffstats
path: root/lib/models/templateBlock.js
diff options
context:
space:
mode:
authorSamy Pessé <samypesse@gmail.com>2016-04-25 13:52:56 +0200
committerSamy Pessé <samypesse@gmail.com>2016-04-25 13:52:56 +0200
commit4aed2cf65240abb26384d7d86ccb27b171e6bb9a (patch)
tree949ede45c93c37215c44bd1b190248d7669501b0 /lib/models/templateBlock.js
parent244fb0ca28f29ac429f58e0e885d21cc6c40beba (diff)
downloadgitbook-4aed2cf65240abb26384d7d86ccb27b171e6bb9a.zip
gitbook-4aed2cf65240abb26384d7d86ccb27b171e6bb9a.tar.gz
gitbook-4aed2cf65240abb26384d7d86ccb27b171e6bb9a.tar.bz2
Add post processing for templates
Diffstat (limited to 'lib/models/templateBlock.js')
-rw-r--r--lib/models/templateBlock.js23
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/models/templateBlock.js b/lib/models/templateBlock.js
index cce636e..4094b89 100644
--- a/lib/models/templateBlock.js
+++ b/lib/models/templateBlock.js
@@ -9,12 +9,24 @@ var NODE_ENDARGS = '%%endargs%%';
var blockBodies = {};
var TemplateBlock = Immutable.Record({
+ // Name of block, also the start tag
name: String(),
+
+ // End tag, default to "end<name>"
end: String(),
+
+ // Function to process the block content
process: Function(),
+
+ // List of String, for inner block tags
blocks: Immutable.List(),
+
+ // List of shortcuts to replace with this block
shortcuts: Immutable.List(),
+
+ // Function to execute in post processing
post: null,
+
parse: true
}, 'TemplateBlock');
@@ -208,6 +220,7 @@ TemplateBlock.prototype.handleBlockResult = function(result) {
if (is.string(result)) {
result = { body: result };
}
+ result.name = this.getName();
return result;
};
@@ -251,6 +264,16 @@ TemplateBlock.indexBlockResult = function(blk) {
};
/**
+ Get a block results indexed for a specific key
+
+ @param {String} key
+ @return {Object|undefined}
+*/
+TemplateBlock.getBlockResultByKey = function(key) {
+ return blockBodies[key];
+};
+
+/**
Create a template block from a function or an object
@param {String} blockName